Esempio n. 1
0
		private void sandDockManager1_DockControlAdded(object sender, TD.SandDock.DockControlEventArgs e)
		{
			AppendLog("DockControl Added: " + e.DockControl.Text);

			e.DockControl.AutoHidePopupOpened += new EventHandler(OnDockControlAutoHidePopupOpened);
			e.DockControl.AutoHidePopupClosed += new EventHandler(OnDockControlAutoHidePopupClosed);
			e.DockControl.Closed += new EventHandler(OnDockControlClosed);
			e.DockControl.Load += new EventHandler(OnDockControlLoad);
			e.DockControl.DockSituationChanged += new EventHandler(OnDockControlDockSituationChanged);
		}
        private void MenuItem_BeforePopup(object sender, TD.SandBar.MenuPopupEventArgs e) {
            try {
                if (sender == this.dropDownMenuItemValidator) {
                    // Get Validator
                    this.menuButtonItemPGdb.Checked = (WorkspaceValidator.Default.Validator is PersonalGeodatabaseValidator);
                    this.menuButtonItemFGdb.Checked = (WorkspaceValidator.Default.Validator is FileGeodatabaseValidator);

                    // Clear SDE Connection Items
                    this.menuButtonItemSdeConnection.Items.Clear();

                    // Find ArcCatalog SDE Connections
                    string applicationData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                    string esri = System.IO.Path.Combine(applicationData, "ESRI");
                    string arcCatalog = System.IO.Path.Combine(esri, "ArcCatalog");
                    if (!Directory.Exists(arcCatalog)) {
                        MenuButtonItem menuButton = new MenuButtonItem();
                        menuButton.Enabled = false;
                        menuButton.Text = Resources.TEXT_NOT_AVAILABLE_BR;
                        this.menuButtonItemSdeConnection.Items.Add(menuButton);
                        return;
                    }

                    // Get List of SDE Connections
                    string[] files = Directory.GetFiles(arcCatalog, "*.sde", SearchOption.TopDirectoryOnly);
                    if (files.Length == 0) {
                        MenuButtonItem menuButton = new MenuButtonItem();
                        menuButton.Enabled = false;
                        menuButton.Text = Resources.TEXT_NONE_BR;
                        this.menuButtonItemSdeConnection.Items.Add(menuButton);
                        return;
                    }

                    // Add an Item for each SDE Connection
                    foreach (string file in files) {
                        string filename = System.IO.Path.GetFileNameWithoutExtension(file);
                        MenuButtonItem menuButton = new MenuButtonItem();
                        menuButton.Enabled = true;
                        menuButton.Text = filename;
                        menuButton.Tag = file;
                        menuButton.Activate += new EventHandler(this.MenuItem_Activate);
                        this.menuButtonItemSdeConnection.Items.Add(menuButton);
                    }
                }
                else if (sender == this.menuButtonItemSdeConnection) {
                    // Get SDE Validator
                    SdeValidator sdeValidator = WorkspaceValidator.Default.Validator as SdeValidator;
                    if (sdeValidator == null) { return; }

                    // Check if SDE Connection File match
                    foreach (MenuButtonItem item in this.menuButtonItemSdeConnection.Items) {
                        if (item.Tag == null) { continue; }
                        string itemTag = item.Tag.ToString();
                        item.Checked = (itemTag == sdeValidator.SdeFile);
                    }
                }
                else if (sender == this.contextMenuBarItemErrorList) {
                    this.menuButtonItemScroll.Enabled = (this.listViewErrorList.SelectedItems.Count == 1);
                    this.menuButtonItemSelect.Enabled = (this.listViewErrorList.SelectedItems.Count > 0);
                    this.menuButtonItemFlashError.Enabled = (this.listViewErrorList.SelectedItems.Count > 0);
                    this.menuButtonItemClearError.Enabled = (this.listViewErrorList.SelectedItems.Count > 0);
                    this.menuButtonItemClearAllErrors.Enabled = (this.listViewErrorList.Items.Count > 0);
                }
            }
            catch (Exception ex) {
                ExceptionDialog.HandleException(ex);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Document closing event.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void GettingStarted_Closing(object sender, TD.SandDock.DockControlClosingEventArgs e)
 {
     this.ApplicationForm.CloseGettingStarted();
 }
Esempio n. 4
0
        private void toolBarFormatting_ButtonClick(object sender, TD.SandBar.ToolBarItemEventArgs e)
        {
            string selectedText = richTextBox1.SelectedText;

            if (e.Item == buttonItemBold)
            {
                richTextBox1.SelectedText = String.Format("{0}{1}{2}", "*", selectedText, "*");
            }
            else if (e.Item == buttonItemItalic)
            {
                richTextBox1.SelectedText = String.Format("{0}{1}{2}", "_", selectedText, "_");
            }
            else if (e.Item == buttonItemUnderline)
            {
                richTextBox1.SelectedText = String.Format("{0}{1}{2}", "+", selectedText, "+");
            }
            else if (e.Item == buttonItemOrderedList)
            {
                richTextBox1.SelectedText = FormatList(selectedText, "1. ");
            }
            else if (e.Item == buttonItemUnorderedList)
            {
                richTextBox1.SelectedText = FormatList(selectedText, "* ");
            }
            else if (e.Item == buttonItemInsertLink)
            {
                richTextBox1.SelectedText = String.Format("\"{0}\":{1}", selectedText, "<enterUrl>");
            }
            else if (e.Item == buttonItemInsertHorizonalRule)
            {
                richTextBox1.SelectedText = String.Format("{0}\n{1}", "----", selectedText);
            }
        }
Esempio n. 5
0
 private void menuBar1_ButtonClick(object sender, TD.SandBar.ToolBarItemEventArgs e)
 {
 }
Esempio n. 6
0
        private static void OnScheduledWork(object state)
        {
            Scheduler thisPtr = (Scheduler)state;

            // We snapshot these values here so that we can
            // use them after calling OnSchedulerIdle.
            bool isTracingEnabled   = TD.IsEnd2EndActivityTracingEnabled() && TD.ShouldTraceToTraceSource(EventLevel.Informational);
            Guid oldActivityId      = Guid.Empty;
            Guid workflowInstanceId = Guid.Empty;

            if (isTracingEnabled)
            {
                oldActivityId      = TD.CurrentActivityId;
                workflowInstanceId = thisPtr._callbacks.WorkflowInstanceId;
                TD.TraceTransfer(workflowInstanceId);

                if (thisPtr._resumeTraceRequired)
                {
                    if (TD.WorkflowActivityResumeIsEnabled())
                    {
                        TD.WorkflowActivityResume(workflowInstanceId);
                    }
                }
            }

            thisPtr._callbacks.ThreadAcquired();

            RequestedAction nextAction   = s_continueAction;
            bool            idleOrPaused = false;

            while (object.ReferenceEquals(nextAction, s_continueAction))
            {
                if (thisPtr.IsIdle || thisPtr._isPausing)
                {
                    idleOrPaused = true;
                    break;
                }

                // cycle through (queue->thisPtr.firstWorkItem->currentWorkItem)
                WorkItem currentWorkItem = thisPtr._firstWorkItem;

                // promote an item out of our work queue if necessary
                if (thisPtr._workItemQueue != null && thisPtr._workItemQueue.Count > 0)
                {
                    thisPtr._firstWorkItem = thisPtr._workItemQueue.Dequeue();
                }
                else
                {
                    thisPtr._firstWorkItem = null;
                }

                if (TD.ExecuteWorkItemStartIsEnabled())
                {
                    TD.ExecuteWorkItemStart();
                }

                nextAction = thisPtr._callbacks.ExecuteWorkItem(currentWorkItem);

                if (TD.ExecuteWorkItemStopIsEnabled())
                {
                    TD.ExecuteWorkItemStop();
                }
            }

            bool notifiedCompletion = false;
            bool isInstanceComplete = false;

            if (idleOrPaused || object.ReferenceEquals(nextAction, s_abortAction))
            {
                thisPtr._isPausing = false;
                thisPtr._isRunning = false;

                thisPtr.NotifyWorkCompletion();
                notifiedCompletion = true;

                if (isTracingEnabled)
                {
                    isInstanceComplete = thisPtr._callbacks.IsCompleted;
                }

                // After calling SchedulerIdle we no longer have the lock.  That means
                // that any subsequent processing in this method won't have the single
                // threaded guarantee.
                thisPtr._callbacks.SchedulerIdle();
            }
            else if (!object.ReferenceEquals(nextAction, s_yieldSilentlyAction))
            {
                Fx.Assert(nextAction is NotifyUnhandledExceptionAction, "This is the only other option");

                NotifyUnhandledExceptionAction notifyAction = (NotifyUnhandledExceptionAction)nextAction;

                // We only set isRunning back to false so that the host doesn't
                // have to treat this like a pause notification.  As an example,
                // a host could turn around and call run again in response to
                // UnhandledException without having to go through its operation
                // dispatch loop first (or request pause again).  If we reset
                // isPausing here then any outstanding operations wouldn't get
                // signaled with that type of host.
                thisPtr._isRunning = false;

                thisPtr.NotifyWorkCompletion();
                notifiedCompletion = true;

                if (isTracingEnabled)
                {
                    isInstanceComplete = thisPtr._callbacks.IsCompleted;
                }

                thisPtr._callbacks.NotifyUnhandledException(notifyAction.Exception, notifyAction.Source);
            }

            if (isTracingEnabled)
            {
                if (notifiedCompletion)
                {
                    if (isInstanceComplete)
                    {
                        if (TD.WorkflowActivityStopIsEnabled())
                        {
                            TD.WorkflowActivityStop(workflowInstanceId);
                        }
                    }
                    else
                    {
                        if (TD.WorkflowActivitySuspendIsEnabled())
                        {
                            TD.WorkflowActivitySuspend(workflowInstanceId);
                        }
                    }
                }

                TD.CurrentActivityId = oldActivityId;
            }
        }
Esempio n. 7
0
            public override bool CheckAccess(EndpointIdentity identity, AuthorizationContext authContext)
            {
                EventTraceActivity eventTraceActivity = null;

                if (identity == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("identity");
                }

                if (authContext == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("authContext");
                }


                if (FxTrace.Trace.IsEnd2EndActivityTracingEnabled)
                {
                    eventTraceActivity = EventTraceActivityHelper.TryExtractActivity((OperationContext.Current != null) ? OperationContext.Current.IncomingMessage : null);
                }

                for (int i = 0; i < authContext.ClaimSets.Count; ++i)
                {
                    ClaimSet claimSet = authContext.ClaimSets[i];
                    if (claimSet.ContainsClaim(identity.IdentityClaim))
                    {
                        SecurityTraceRecordHelper.TraceIdentityVerificationSuccess(eventTraceActivity, identity, identity.IdentityClaim, this.GetType());
                        return(true);
                    }

                    // try Claim equivalence
                    string expectedSpn = null;
                    if (ClaimTypes.Dns.Equals(identity.IdentityClaim.ClaimType))
                    {
                        expectedSpn = string.Format(CultureInfo.InvariantCulture, "host/{0}", (string)identity.IdentityClaim.Resource);
                        Claim claim = CheckDnsEquivalence(claimSet, expectedSpn);
                        if (claim != null)
                        {
                            SecurityTraceRecordHelper.TraceIdentityVerificationSuccess(eventTraceActivity, identity, claim, this.GetType());
                            return(true);
                        }
                    }
                    // Allow a Sid claim to support UPN, and SPN identities
                    SecurityIdentifier identitySid = null;
                    if (ClaimTypes.Sid.Equals(identity.IdentityClaim.ClaimType))
                    {
                        identitySid = GetSecurityIdentifier(identity.IdentityClaim);
                    }
                    else if (ClaimTypes.Upn.Equals(identity.IdentityClaim.ClaimType))
                    {
                        identitySid = ((UpnEndpointIdentity)identity).GetUpnSid();
                    }
                    else if (ClaimTypes.Spn.Equals(identity.IdentityClaim.ClaimType))
                    {
                        identitySid = ((SpnEndpointIdentity)identity).GetSpnSid();
                    }
                    else if (ClaimTypes.Dns.Equals(identity.IdentityClaim.ClaimType))
                    {
                        identitySid = new SpnEndpointIdentity(expectedSpn).GetSpnSid();
                    }
                    if (identitySid != null)
                    {
                        Claim claim = CheckSidEquivalence(identitySid, claimSet);
                        if (claim != null)
                        {
                            SecurityTraceRecordHelper.TraceIdentityVerificationSuccess(eventTraceActivity, identity, claim, this.GetType());
                            return(true);
                        }
                    }
                }
                SecurityTraceRecordHelper.TraceIdentityVerificationFailure(identity, authContext, this.GetType());
                if (TD.SecurityIdentityVerificationFailureIsEnabled())
                {
                    TD.SecurityIdentityVerificationFailure(eventTraceActivity);
                }

                return(false);
            }
Esempio n. 8
0
        internal BookmarkScope CreateAndRegisterScope(Guid scopeId, BookmarkScopeHandle scopeHandle)
        {
            if (_bookmarkManagers == null)
            {
                _bookmarkManagers = new Dictionary <BookmarkScope, BookmarkManager>();
            }

            BookmarkScope scope = null;

            if (scopeId == Guid.Empty)
            {
                //
                // This is the very first activity which started the sub-instance
                //
                scope = new BookmarkScope(GetNextTemporaryId());
                _bookmarkManagers.Add(scope, new BookmarkManager(scope, scopeHandle));

                if (TD.CreateBookmarkScopeIsEnabled())
                {
                    TD.CreateBookmarkScope(ActivityUtilities.GetTraceString(scope));
                }

                if (_uninitializedScopes == null)
                {
                    _uninitializedScopes = new List <BookmarkScope>();
                }

                _uninitializedScopes.Add(scope);
            }
            else
            {
                //
                // Try to find one in the existing sub-instances
                //
                foreach (BookmarkScope eachScope in _bookmarkManagers.Keys)
                {
                    if (eachScope.Id.Equals(scopeId))
                    {
                        scope = eachScope;
                        break;
                    }
                }

                //
                // We did not find one, e.g. the first receive will get the correlation id from the
                // correlation channel
                //
                if (scope == null)
                {
                    scope = new BookmarkScope(scopeId);
                    _bookmarkManagers.Add(scope, new BookmarkManager(scope, scopeHandle));

                    if (TD.CreateBookmarkScopeIsEnabled())
                    {
                        TD.CreateBookmarkScope(string.Format(CultureInfo.InvariantCulture, "Id: {0}", ActivityUtilities.GetTraceString(scope)));
                    }
                }

                CreateAssociatedKey(scope);
            }

            return(scope);
        }
        /*
         *   Negotiation consists of the following steps (some may be async in the async case):
         *   1. Create negotiation state
         *   2. Initialize channel factories
         *   3. Create an channel
         *   4. Open the channel
         *   5. Create the next message to send to server
         *   6. Send the message and get reply
         *   8. Process incoming message and get next outgoing message.
         *   9. If no outgoing message, then negotiation is over. Go to step 11.
         *   10. Goto step 6
         *   11. Close the IRequest channel and complete
         */
        protected SecurityToken DoNegotiation(TimeSpan timeout)
        {
            ThrowIfClosedOrCreated();
            SecurityTraceRecordHelper.TraceBeginSecurityNegotiation(this, this.targetAddress);
            TimeoutHelper   timeoutHelper = new TimeoutHelper(timeout);
            IRequestChannel rstChannel    = null;
            T        negotiationState     = null;
            TimeSpan timeLeft             = timeout;
            int      legs = 1;

            try
            {
                negotiationState = this.CreateNegotiationState(this.targetAddress, this.via, timeoutHelper.RemainingTime());
                InitializeNegotiationState(negotiationState);
                this.InitializeChannelFactories(negotiationState.RemoteAddress, timeoutHelper.RemainingTime());
                rstChannel = this.CreateClientChannel(negotiationState.RemoteAddress, this.via);
                rstChannel.Open(timeoutHelper.RemainingTime());
                Message       nextOutgoingMessage = null;
                Message       incomingMessage     = null;
                SecurityToken serviceToken        = null;
                for (;;)
                {
                    nextOutgoingMessage = this.GetNextOutgoingMessage(incomingMessage, negotiationState);
                    if (incomingMessage != null)
                    {
                        incomingMessage.Close();
                    }
                    if (nextOutgoingMessage != null)
                    {
                        using (nextOutgoingMessage)
                        {
                            EventTraceActivity eventTraceActivity = null;
                            if (TD.MessageSentToTransportIsEnabled())
                            {
                                eventTraceActivity = EventTraceActivityHelper.TryExtractActivity(nextOutgoingMessage);
                            }

                            TraceUtility.ProcessOutgoingMessage(nextOutgoingMessage, eventTraceActivity);
                            timeLeft        = timeoutHelper.RemainingTime();
                            incomingMessage = rstChannel.Request(nextOutgoingMessage, timeLeft);
                            if (incomingMessage == null)
                            {
                                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(SR.GetString(SR.FailToRecieveReplyFromNegotiation)));
                            }

                            if (eventTraceActivity == null && TD.MessageReceivedFromTransportIsEnabled())
                            {
                                eventTraceActivity = EventTraceActivityHelper.TryExtractActivity(incomingMessage);
                            }

                            TraceUtility.ProcessIncomingMessage(incomingMessage, eventTraceActivity);
                        }
                        legs += 2;
                    }
                    else
                    {
                        if (!negotiationState.IsNegotiationCompleted)
                        {
                            throw TraceUtility.ThrowHelperError(new SecurityNegotiationException(SR.GetString(SR.NoNegotiationMessageToSend)), incomingMessage);
                        }

                        try
                        {
                            rstChannel.Close(timeoutHelper.RemainingTime());
                        }
                        catch (CommunicationException e)
                        {
                            DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);

                            rstChannel.Abort();
                        }
                        catch (TimeoutException e)
                        {
                            if (TD.CloseTimeoutIsEnabled())
                            {
                                TD.CloseTimeout(e.Message);
                            }
                            DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);

                            rstChannel.Abort();
                        }

                        rstChannel = null;
                        this.ValidateAndCacheServiceToken(negotiationState);
                        serviceToken = negotiationState.ServiceToken;
                        SecurityTraceRecordHelper.TraceEndSecurityNegotiation(this, serviceToken, this.targetAddress);
                        break;
                    }
                }
                return(serviceToken);
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }

                if (e is TimeoutException)
                {
                    e = new TimeoutException(SR.GetString(SR.ClientSecurityNegotiationTimeout, timeout, legs, timeLeft), e);
                }
                EndpointAddress temp = (negotiationState == null) ? null : negotiationState.RemoteAddress;
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(WrapExceptionIfRequired(e, temp, this.issuerAddress));
            }
            finally
            {
                Cleanup(rstChannel, negotiationState);
            }
        }
Esempio n. 10
0
 private List<PropertyGrid> GetPropertyGrids(TD.SandDock.TabControl tabControl) {
     List<PropertyGrid> propertyGrids = new List<PropertyGrid>();
     foreach (TD.SandDock.TabPage tabPage in tabControl.TabPages) {
         if (tabPage.Controls.Count == 0) { continue; }
         if (tabPage.Controls[0] is TD.SandDock.TabControl) {
             TD.SandDock.TabControl tabControl2 = (TD.SandDock.TabControl)tabPage.Controls[0];
             List<PropertyGrid> propertyGrids2 = this.GetPropertyGrids(tabControl2);
             foreach (PropertyGrid propertyGrid2 in propertyGrids2) {
                 propertyGrids.Add(propertyGrid2);
             }
         }
         else if (tabPage.Controls[0] is PropertyGrid){
             propertyGrids.Add((PropertyGrid)tabPage.Controls[0]);
         }
     }
     return propertyGrids;
 }
Esempio n. 11
0
        private PropertyGrid SelectedPropertGrid(TD.SandDock.TabControl tabControl){
            TD.SandDock.TabPage tabPage = tabControl.SelectedPage;
            if (tabPage == null){return null;}
            if (tabPage.Controls.Count == 0){return null;}

            if (tabPage.Controls[0] is TD.SandDock.TabControl) {
                return this.SelectedPropertGrid((TD.SandDock.TabControl)tabPage.Controls[0]);
            }

            if (tabPage.Controls[0] is PropertyGrid) {
                return (PropertyGrid)tabPage.Controls[0];
            }

            return null;
        }
        GenericXmlSecurityToken DoOperation(SecuritySessionOperation operation, EndpointAddress target, Uri via, SecurityToken currentToken, TimeSpan timeout)
        {
            if (target == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("target");
            }
            if (operation == SecuritySessionOperation.Renew && currentToken == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("currentToken");
            }
            IRequestChannel channel = null;

            try
            {
                SecurityTraceRecordHelper.TraceBeginSecuritySessionOperation(operation, target, currentToken);
                channel = this.CreateChannel(operation, target, via);

                TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);
                channel.Open(timeoutHelper.RemainingTime());
                object requestState;
                GenericXmlSecurityToken issuedToken;

                using (Message requestMessage = this.CreateRequest(operation, target, currentToken, out requestState))
                {
                    EventTraceActivity eventTraceActivity = null;
                    if (TD.MessageReceivedFromTransportIsEnabled())
                    {
                        eventTraceActivity = EventTraceActivityHelper.TryExtractActivity(requestMessage);
                    }

                    TraceUtility.ProcessOutgoingMessage(requestMessage, eventTraceActivity);

                    using (Message reply = channel.Request(requestMessage, timeoutHelper.RemainingTime()))
                    {
                        if (reply == null)
                        {
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(SR.GetString(SR.FailToRecieveReplyFromNegotiation)));
                        }

                        if (eventTraceActivity == null && TD.MessageReceivedFromTransportIsEnabled())
                        {
                            eventTraceActivity = EventTraceActivityHelper.TryExtractActivity(reply);
                        }

                        TraceUtility.ProcessIncomingMessage(reply, eventTraceActivity);
                        ThrowIfFault(reply, this.targetAddress);
                        issuedToken = ProcessReply(reply, operation, requestState);
                        ValidateKeySize(issuedToken);
                    }
                }
                channel.Close(timeoutHelper.RemainingTime());
                this.OnOperationSuccess(operation, target, issuedToken, currentToken);
                return(issuedToken);
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }

                if (e is TimeoutException)
                {
                    e = new TimeoutException(SR.GetString(SR.ClientSecuritySessionRequestTimeout, timeout), e);
                }

                OnOperationFailure(operation, target, currentToken, e, channel);
                throw;
            }
        }
Esempio n. 13
0
        static public void Draw(TC_SelectItemGroup selectItemGroup, float activeMulti, int index, bool nodeFoldout, ref Vector2 pos, Color color)
        {
            TC_SelectItem selectItem = selectItemGroup.itemList[index];

            Undo.RecordObject(selectItem, selectItem.name);

            Rect rectPreview;
            bool isCulled = false;

            if (selectItem.outputId == TC.colorOutput)
            {
                if (selectItem.texColor != null && selectItem.parentItem.itemList.Count == 1)
                {
                    rectPreview = TD.DrawNode(selectItem, pos, color, Color.white, ref isCulled, activeMulti, nodeFoldout, false, false);
                }
                else
                {
                    rectPreview = TD.DrawNode(selectItem, pos, color, selectItem.color, ref isCulled, activeMulti, nodeFoldout, false, false);
                }
            }
            else
            {
                rectPreview = TD.DrawNode(selectItem, pos, color, Color.white, ref isCulled, activeMulti, nodeFoldout, false, !selectItem.splatCustom);
            }
            if (isCulled || !nodeFoldout)
            {
                return;
            }

            if (TC_Settings.instance.hasMasterTerrain)
            {
                Vector2 sliderPos = TD.GetPositionScaled(new Vector2(pos.x + 10.5f, pos.y + 297.5f));
                GUIUtility.ScaleAroundPivot(new Vector2(TD.scale * 2.25f, TD.scale * 2.25f), new Vector2(sliderPos.x, sliderPos.y));

                if (selectItem.outputId != TC.objectOutput)
                {
                    if (selectItem.outputId == TC.colorOutput)
                    {
                        Color colOld = selectItem.color;
                        if (Event.current.button != 2)
                        {
                            selectItem.color = EditorGUI.ColorField(new Rect(sliderPos.x, sliderPos.y + 4, 93, 10), selectItem.color);
                        }
                        else
                        {
                            EditorGUI.ColorField(new Rect(sliderPos.x, sliderPos.y + 4, 93, 10), selectItem.color);
                        }
                        selectItem.color.a = 1;
                        if (selectItem.color != colOld)
                        {
                            selectItem.Refresh();
                        }
                    }
                    else
                    {
                        int selectIndexOld = selectItem.selectIndex;
                        int total          = selectItem.GetItemTotalFromTerrain();
                        if (total > 1)
                        {
                            if (selectItem.outputId == TC.treeOutput)
                            {
                                sliderPos.y -= 17;
                            }
                            if (Event.current.button != 2)
                            {
                                selectItem.selectIndex = (int)GUI.HorizontalSlider(new Rect(sliderPos.x, sliderPos.y, 110, 16), selectItem.selectIndex, 0, total - 1);
                            }
                            else
                            {
                                GUI.HorizontalSlider(new Rect(sliderPos.x, sliderPos.y, 110, 16), selectItem.selectIndex, 0, total - 1);
                            }
                        }

                        if (selectItem.selectIndex != selectIndexOld)
                        {
                            selectItem.Refresh();
                        }
                    }
                }

                if (selectItem.outputId == TC.splatOutput)
                {
                    // if (selectItem.splatCustom) DrawSplatCustomPreview(selectItem, rectPreview);
                }

                GUI.matrix = Matrix4x4.Scale(new Vector3(1, 1, 1));

                TC_NodeGUI.DrawAddItem(rectPreview, pos, selectItem);
                TC_NodeGUI.LeftClickMenu(rectPreview, selectItem);
            }

            if (selectItem.outputId != TC.colorOutput)
            {
                Rect colorRect = new Rect(rectPreview.x + 0 * TD.scale, rectPreview.y + 0 * TD.scale, 60 * TD.scale, 16f * TD.scale);
                GUI.color = new Color(selectItem.color.r, selectItem.color.g, selectItem.color.b, 0.75f);
                GUI.DrawTexture(colorRect, Texture2D.whiteTexture);
                GUI.color = Color.white;
            }
        }
Esempio n. 14
0
        bool HandleClientOperationFailure(Exception e)
        {
            if (TD.RoutingServiceTransmitFailedIsEnabled())
            {
                TD.RoutingServiceTransmitFailed(null, this.client.Key.ToString(), e);
            }

            if (!(e is CommunicationException || e is TimeoutException))
            {
                //We only move to backup for CommunicationExceptions and TimeoutExceptions
                return(false);
            }

            bool          canHandle;
            MessageRpc    messageRpc    = this.service.SessionMessages[this.sessionMessageIndex];
            SendOperation sendOperation = messageRpc.Operations[this.destinationIndex];

            if ((e is CommunicationObjectAbortedException || e is CommunicationObjectFaultedException) &&
                !this.channelExtension.HasSession)
            {
                // Messages on a non sessionful channel share outbound connections and can
                // fail due to other messages failing on the same channel
                bool canRetry = (this.channelExtension.ReceiveContextEnabled || !this.channelExtension.TransactedReceiveEnabled);
                if (canRetry && !this.abortedRetry)
                {
                    //No session and ReceiveContext or non transactional, retry the message 1 time (before moving to backup)
                    this.abortedRetry = true;
                    this.ResetState();
                    return(true);
                }
            }
            else if (e is EndpointNotFoundException)
            {
                // The channel may not fault for this exception for bindings other than netTcpBinding
                // We abort the channel in that case. We proactively clean up so that we don't have to cleanup later
                SessionChannels sessionChannels = this.service.GetSessionChannels(messageRpc.Impersonating);
                if (sessionChannels != null)
                {
                    sessionChannels.AbortChannel(sendOperation.CurrentEndpoint);
                }
            }
            else if (e is MessageSecurityException)
            {
                // The service may have been stopped and restarted without the routing service knowledge.
                // When we try to use a cached channel to the service, the channel can fault due to this exception
                // The faulted channel gets cleaned up and we retry one more time only when service has backup
                // If there is no backup, we do not retry since we do not create a buffered message to prevent performance degradation
                if (!this.abortedRetry && (sendOperation.AlternateEndpointCount > 0))
                {
                    this.abortedRetry = true;
                    this.ResetState();
                    return(true);
                }
            }

            if (sendOperation.TryMoveToAlternate(e))
            {
                if (TD.RoutingServiceMovedToBackupIsEnabled())
                {
                    TD.RoutingServiceMovedToBackup(messageRpc.EventTraceActivity, messageRpc.UniqueID, this.destinationIndex.ToString(TD.Culture), sendOperation.CurrentEndpoint.ToString());
                }
                this.ResetState();
                canHandle = true;
            }
            else if (this.service.GetTransactionForSending(messageRpc) == null)
            {
                // This is OneWay with no Transaction...
                // store this exception for when we complete, but continue any multicasting
                this.service.SessionException = e;

                // Mark the SendOperation as 'Sent' because there's no more work we can do (non-tx and no more backups)
                sendOperation.TransmitSucceeded(null);

                if (this.channelExtension.HasSession)
                {
                    this.channelExtension.SessionChannels.AbortChannel(this.client.Key);
                }

                this.MoveToNextClientOperation(messageRpc.Operations.Count);
                canHandle = true;
            }
            else
            {
                canHandle = false;
            }

            return(canHandle);
        }
Esempio n. 15
0
        bool SendToCurrentClient()
        {
            MessageRpc    messageRpc    = this.service.SessionMessages[this.sessionMessageIndex];
            SendOperation sendOperation = messageRpc.Operations[this.destinationIndex];

            if (sendOperation.Sent)
            {
                this.MoveToNextClientOperation(messageRpc.Operations.Count);
                return(true);
            }
            else if (!this.channelExtension.ReceiveContextEnabled &&
                     this.channelExtension.TransactedReceiveEnabled &&
                     sendOperation.HasAlternate)
            {
                // We can't do error handling for oneway Transactional unless there's RC.
                throw FxTrace.Exception.AsError(new ConfigurationErrorsException(SR.ErrorHandlingNotSupportedTxNoRC(messageRpc.OperationContext.Channel.LocalAddress)));
            }

            RoutingEndpointTrait endpointTrait = sendOperation.CurrentEndpoint;

            this.client = this.service.GetOrCreateClient <TContract>(endpointTrait, messageRpc.Impersonating);
            try
            {
                // We always work on cloned message when there are backup endpoints to handle exception cases
                Message message;
                if (messageRpc.Operations.Count == 1 && sendOperation.AlternateEndpointCount == 0)
                {
                    message = messageRpc.Message;
                }
                else
                {
                    message = messageRpc.CreateBuffer().CreateMessage();
                }

                sendOperation.PrepareMessage(message);
                IAsyncResult result;

                if (TD.RoutingServiceTransmittingMessageIsEnabled())
                {
                    TD.RoutingServiceTransmittingMessage(messageRpc.EventTraceActivity, messageRpc.UniqueID, this.destinationIndex.ToString(TD.Culture), this.client.Key.ToString());
                }

                Transaction transaction = this.service.GetTransactionForSending(messageRpc);
                using (this.PrepareTransactionalCall(transaction))
                {
                    IDisposable impersonationContext = null;
                    try
                    {
                        //Perform the assignment in a finally block so it won't be interrupted asynchronously
                        try { }
                        finally
                        {
                            impersonationContext = messageRpc.PrepareCall();
                        }

                        result = this.client.BeginOperation(message, transaction, this.PrepareAsyncCompletion(clientOperationCallback), this);
                    }
                    finally
                    {
                        if (impersonationContext != null)
                        {
                            impersonationContext.Dispose();
                        }
                    }
                }

                if (this.CheckSyncContinue(result))
                {
                    this.ClientOperationComplete(result);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }

                //See if we can handle this Exception...
                if (this.HandleClientOperationFailure(exception))
                {
                    return(true);
                }
                throw;
            }
        }
        void SerializeOutputs(ref MessageRpc rpc)
        {
            if (!this.IsOneWay && this.parent.EnableFaults)
            {
                Message reply;
                if (this.serializeReply)
                {
                    try
                    {
                        if (TD.DispatchFormatterSerializeReplyStartIsEnabled())
                        {
                            TD.DispatchFormatterSerializeReplyStart(rpc.EventTraceActivity);
                        }

                        bool      outputTiming = DS.MessageFormatterIsEnabled();
                        Stopwatch sw           = null;
                        if (outputTiming)
                        {
                            sw = Stopwatch.StartNew();
                        }

                        reply = this.Formatter.SerializeReply(rpc.RequestVersion, rpc.OutputParameters, rpc.ReturnParameter);

                        if (outputTiming)
                        {
                            DS.DispatchMessageFormatterSerialize(this.Formatter.GetType(), sw.Elapsed);
                        }

                        if (TD.DispatchFormatterSerializeReplyStopIsEnabled())
                        {
                            TD.DispatchFormatterSerializeReplyStop(rpc.EventTraceActivity);
                        }
                    }
                    catch (Exception e)
                    {
                        if (Fx.IsFatal(e))
                        {
                            throw;
                        }
                        if (ErrorBehavior.ShouldRethrowExceptionAsIs(e))
                        {
                            throw;
                        }
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
                    }

                    if (reply == null)
                    {
                        string message = SR.GetString(SR.SFxNullReplyFromFormatter2, this.Formatter.GetType().ToString(), (this.name ?? ""));
                        ErrorBehavior.ThrowAndCatch(new InvalidOperationException(message));
                    }
                }
                else
                {
                    if ((rpc.ReturnParameter == null) && (rpc.OperationContext.RequestContext != null))
                    {
                        string message = SR.GetString(SR.SFxDispatchRuntimeMessageCannotBeNull, this.name);
                        ErrorBehavior.ThrowAndCatch(new InvalidOperationException(message));
                    }

                    reply = (Message)rpc.ReturnParameter;

                    if ((reply != null) && (!ProxyOperationRuntime.IsValidAction(reply, this.ReplyAction)))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxInvalidReplyAction, this.Name, reply.Headers.Action ?? "{NULL}", this.ReplyAction)));
                    }
                }

                if (DiagnosticUtility.ShouldUseActivity && rpc.Activity != null && reply != null)
                {
                    TraceUtility.SetActivity(reply, rpc.Activity);
                    if (TraceUtility.ShouldPropagateActivity)
                    {
                        TraceUtility.AddActivityHeader(reply);
                    }
                }
                else if (TraceUtility.ShouldPropagateActivity && reply != null && rpc.ResponseActivityId != Guid.Empty)
                {
                    ActivityIdHeader header = new ActivityIdHeader(rpc.ResponseActivityId);
                    header.AddTo(reply);
                }

                //rely on the property set during the message receive to correlate the trace
                if (TraceUtility.MessageFlowTracingOnly)
                {
                    //Guard against MEX scenarios where the message is closed by now
                    if (null != rpc.OperationContext.IncomingMessage && MessageState.Closed != rpc.OperationContext.IncomingMessage.State)
                    {
                        FxTrace.Trace.SetAndTraceTransfer(TraceUtility.GetReceivedActivityId(rpc.OperationContext), true);
                    }
                    else
                    {
                        if (rpc.ResponseActivityId != Guid.Empty)
                        {
                            FxTrace.Trace.SetAndTraceTransfer(rpc.ResponseActivityId, true);
                        }
                    }
                }

                // Add the ImpersonateOnSerializingReplyMessageProperty on the reply message iff
                // a. reply message is not null.
                // b. Impersonation is enabled on serializing Reply

                if (reply != null && this.parent.IsImpersonationEnabledOnSerializingReply)
                {
                    bool shouldImpersonate = this.parent.SecurityImpersonation != null && this.parent.SecurityImpersonation.IsImpersonationEnabledOnCurrentOperation(ref rpc);
                    if (shouldImpersonate)
                    {
                        reply.Properties.Add(ImpersonateOnSerializingReplyMessageProperty.Name, new ImpersonateOnSerializingReplyMessageProperty(ref rpc));
                        reply = new ImpersonatingMessage(reply);
                    }
                }

                if (MessageLogger.LoggingEnabled && null != reply)
                {
                    MessageLogger.LogMessage(ref reply, MessageLoggingSource.ServiceLevelSendReply | MessageLoggingSource.LastChance);
                }
                rpc.Reply = reply;
            }
        }
Esempio n. 17
0
		/// <summary>
		/// Constructs the object with all of the environments primary controls.
		/// </summary>
		/// <param name="qSetExplorer">Primary QSetExplorer.</param>
		/// <param name="qSetMonitor">Primary QSetMonitor.</param>
		/// <param name="propertyGrid">Primary property grid.</param>
		/// <param name="messageViewer">Primary MessageViewer.</param>
		/// <param name="documentContainer">Primary DocumentContainer.</param>
		/// <param name="images">Images component.</param>
		public PrimaryControls(
			QSetExplorer qSetExplorer,
			QSetMonitor qSetMonitor,
			PropertyGrid propertyGrid,
			MessageViewer messageViewer,
			TD.SandDock.DocumentContainer documentContainer,
			Images images)
		{
			_qSetExplorer = qSetExplorer;
			_qSetMonitor = qSetMonitor;
			_propertyGrid = propertyGrid;
			_messageViewer = messageViewer;
			_documentContainer = documentContainer;		
			_images = images;

			_messageBrowserCollection = new MessageBrowserCollection();
			_webServiceClientControlCollection = new WebServiceClientControlCollection();
		}
        public void Authorize(ref MessageRpc rpc)
        {
            if (TD.DispatchMessageBeforeAuthorizationIsEnabled())
            {
                TD.DispatchMessageBeforeAuthorization(rpc.EventTraceActivity);
            }

            SecurityMessageProperty security = SecurityMessageProperty.GetOrCreate(rpc.Request);

            security.ExternalAuthorizationPolicies = this.externalAuthorizationPolicies;

            ServiceAuthorizationManager serviceAuthorizationManager = this.serviceAuthorizationManager ?? DefaultServiceAuthorizationManager;
            bool      outputTiming = DS.AuthorizationIsEnabled();
            Stopwatch sw           = null;

            if (outputTiming)
            {
                sw = Stopwatch.StartNew();
            }

            try
            {
                if (!serviceAuthorizationManager.CheckAccess(rpc.OperationContext, ref rpc.Request))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateAccessDeniedFaultException());
                }

                if (outputTiming)
                {
                    DS.Authorization(this.serviceAuthorizationManager.GetType(), true, sw.Elapsed);
                }
            }
            catch (Exception ex)
            {
                if (Fx.IsFatal(ex))
                {
                    throw;
                }

                if (outputTiming)
                {
                    DS.Authorization(this.serviceAuthorizationManager.GetType(), false, sw.Elapsed);
                }

                if (PerformanceCounters.PerformanceCountersEnabled)
                {
                    PerformanceCounters.AuthorizationFailed(rpc.Operation.Name);
                }

                if (AuditLevel.Failure == (this.serviceAuthorizationAuditLevel & AuditLevel.Failure))
                {
                    try
                    {
                        string primaryIdentity;
                        string authContextId             = null;
                        AuthorizationContext authContext = security.ServiceSecurityContext.AuthorizationContext;
                        if (authContext != null)
                        {
                            primaryIdentity = SecurityUtils.GetIdentityNamesFromContext(authContext);
                            authContextId   = authContext.Id;
                        }
                        else
                        {
                            primaryIdentity = SecurityUtils.AnonymousIdentity.Name;
                            authContextId   = "<null>";
                        }

                        SecurityAuditHelper.WriteServiceAuthorizationFailureEvent(this.auditLogLocation,
                                                                                  this.suppressAuditFailure, rpc.Request, rpc.Request.Headers.To, rpc.Request.Headers.Action,
                                                                                  primaryIdentity, authContextId,
                                                                                  serviceAuthorizationManager == DefaultServiceAuthorizationManager ? "<default>" : serviceAuthorizationManager.GetType().Name,
                                                                                  ex);
                    }
#pragma warning suppress 56500
                    catch (Exception auditException)
                    {
                        if (Fx.IsFatal(auditException))
                        {
                            throw;
                        }

                        DiagnosticUtility.TraceHandledException(auditException, TraceEventType.Error);
                    }
                }
                throw;
            }

            if (AuditLevel.Success == (this.serviceAuthorizationAuditLevel & AuditLevel.Success))
            {
                string primaryIdentity;
                string authContextId;
                AuthorizationContext authContext = security.ServiceSecurityContext.AuthorizationContext;
                if (authContext != null)
                {
                    primaryIdentity = SecurityUtils.GetIdentityNamesFromContext(authContext);
                    authContextId   = authContext.Id;
                }
                else
                {
                    primaryIdentity = SecurityUtils.AnonymousIdentity.Name;
                    authContextId   = "<null>";
                }

                SecurityAuditHelper.WriteServiceAuthorizationSuccessEvent(this.auditLogLocation,
                                                                          this.suppressAuditFailure, rpc.Request, rpc.Request.Headers.To, rpc.Request.Headers.Action,
                                                                          primaryIdentity, authContextId,
                                                                          serviceAuthorizationManager == DefaultServiceAuthorizationManager ? "<default>" : serviceAuthorizationManager.GetType().Name);
            }
        }
Esempio n. 19
0
        public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state)
        {
            IAsyncResult result;

            if (instance == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxNoServiceObject")));
            }
            if (inputs == null)
            {
                if (this.InputParameterCount > 0)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxInputParametersToServiceNull", new object[] { this.InputParameterCount })));
                }
            }
            else if (inputs.Length != this.InputParameterCount)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxInputParametersToServiceInvalid", new object[] { this.InputParameterCount, inputs.Length })));
            }
            if (PerformanceCounters.PerformanceCountersEnabled)
            {
                PerformanceCounters.MethodCalled(this.beginMethod.Name.Substring("Begin".Length));
            }
            try
            {
                ServiceModelActivity activity      = null;
                Activity             boundActivity = null;
                this.CreateActivityInfo(ref activity, ref boundActivity);
                if (TD.OperationInvokedIsEnabled())
                {
                    TD.OperationInvoked(this.beginMethod.Name.Substring("Begin".Length), TraceUtility.GetCallerInfo(OperationContext.Current));
                }
                if ((TD.OperationCompletedIsEnabled() || TD.OperationFaultedIsEnabled()) || TD.OperationFailedIsEnabled())
                {
                    TraceUtility.UpdateAsyncOperationContextWithStartTime(DateTime.UtcNow.Ticks);
                }
                using (boundActivity)
                {
                    if (DiagnosticUtility.ShouldUseActivity)
                    {
                        string activityName = null;
                        if (this.endMethod == null)
                        {
                            activityName = System.ServiceModel.SR.GetString("ActivityExecuteMethod", new object[] { this.beginMethod.DeclaringType.FullName, this.beginMethod.Name });
                        }
                        else
                        {
                            activityName = System.ServiceModel.SR.GetString("ActivityExecuteAsyncMethod", new object[] { this.beginMethod.DeclaringType.FullName, this.beginMethod.Name, this.endMethod.DeclaringType.FullName, this.endMethod.Name });
                        }
                        ServiceModelActivity.Start(activity, activityName, ActivityType.ExecuteUserCode);
                    }
                    result = this.InvokeBeginDelegate(instance, inputs, callback, state);
                }
                ServiceModelActivity.Stop(activity);
            }
            catch (SecurityException exception)
            {
                DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning);
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(AuthorizationBehavior.CreateAccessDeniedFaultException());
            }
            catch (Exception exception2)
            {
                TraceUtility.TraceUserCodeException(exception2, this.beginMethod);
                throw;
            }
            return(result);
        }
Esempio n. 20
0
 private void ContextMenu_BeforePopup(object sender, TD.SandBar.MenuPopupEventArgs e) {
     try {
         TreeNode treeNode = this.treeView1.SelectedNode;
         this.menuButtonItemScroll.Enabled = (treeNode is TreeNodeTable);
         this.menuButtonItemFlash.Enabled = (treeNode is TreeNodeTable);
     }
     catch (Exception ex) {
         ExceptionDialog.HandleException(ex);
     }
 }
Esempio n. 21
0
        static public void LeftClickMenu(Rect rect, TC_ItemBehaviour item)
        {
            if (TD.ClickRect(rect) != 1)
            {
                return;
            }

            string itemText = "";

            if (item.GetType() == typeof(TC_SelectItem))
            {
                itemText = "Item";
            }
            else
            {
                itemText = "Node";
            }

            GenericMenu menu = new GenericMenu();

            string instanceID = item.GetInstanceID().ToString();

            if (Event.current.mousePosition.x < rect.x + ((TD.texCardHeader.width / 2) * TD.scale))
            {
                menu.AddItem(new GUIContent("<-- Add " + itemText), false, LeftClickMenu, instanceID + ":Add Left");
                //if (itemText == "Node")
                //{
                //    menu.AddItem(new GUIContent("<-- Add Node Group"), false, LeftClickMenu, instanceID + ":Add NodeGroup Left");
                //    menu.AddSeparator("");
                //}
                menu.AddItem(new GUIContent("<-- Duplicate " + itemText), false, LeftClickMenu, instanceID + ":Duplicate Left");
            }
            else
            {
                menu.AddItem(new GUIContent("--> Add " + itemText), false, LeftClickMenu, instanceID + ":Add Right");
                //if (itemText == "Node")
                //{
                //    menu.AddItem(new GUIContent("--> Add Node Group"), false, LeftClickMenu, instanceID + ":Add NodeGroup Right");
                //    menu.AddSeparator("");
                //}
                menu.AddItem(new GUIContent("--> Duplicate " + itemText), false, LeftClickMenu, instanceID + ":Duplicate Right");
            }

            // bool eraseNodeMenu = true;

            //if (node.nodeType == NodeType.Select)
            //{
            //    TC_NodeGroup nodeGroup = node.t.parent.GetComponent<TC_NodeGroup>();
            //    if (nodeGroup != null)
            //    {
            //        if (nodeGroup.itemList.Count == 1) eraseNodeMenu = false;
            //    }
            //}

            //if (eraseNodeMenu) {
            //    menu.AddSeparator("");
            //    menu.AddItem(new GUIContent("Erase Node"), false, LeftClickMenu, instanceID + ":Erase Node");
            //}

            menu.ShowAsContext();
        }
Esempio n. 22
0
 private ButtonItem AddTool(TD.SandBar.ToolBar toolbar, IToolBase tool, Keys shortcut)
 {
     ButtonItem buttonItem = new ButtonItem();
     buttonItem.Image = tool.GetToolImage();
     buttonItem.ToolTipText = StringUtils.EscapeUIString(tool.GetToolName()) + ((shortcut != Keys.None) ? (" (" + shortcut.ToString() + ")") : "");
     buttonItem.Tag = tool;
     if (tool is ITool)
     {
         buttonItem.Activate += new EventHandler(this.tool_Activate);
     }
     else
     {
         if (tool is IToolAction)
         {
             buttonItem.Activate += new EventHandler(this.toolBase_Activate);
         }
     }
     toolbar.Items.Add(buttonItem);
     this.m_toolItemList.Add(buttonItem);
     if (shortcut != Keys.None)
     {
         this.m_toolShortcuts.Add(shortcut, buttonItem);
     }
     return buttonItem;
 }
Esempio n. 23
0
 /// <summary>
 /// Form closing event.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Roles_Closing(object sender, TD.SandDock.DockControlClosingEventArgs e)
 {
     if (this.FormChanged)
     {
         if (MessageBox.Show("Do you wish to save your changes first?",
             "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             SaveRecord();
         }
     }
 }
Esempio n. 24
0
 private TD.SandBar.ToolBar CreateToolbar(string id, string text, int row, TD.SandBar.ToolBar afterToolbar)
 {
     TD.SandBar.ToolBar toolBar = new TD.SandBar.ToolBar();
     toolBar.Guid = new Guid(id.GetHashCode(), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
     toolBar.DockLine = row;
     toolBar.DockOffset = afterToolbar.DockOffset + afterToolbar.Width;
     this.sandBarManager.AddToolbar(toolBar);
     toolBar.Redock(this.sandBarManager.FindSuitableContainer(DockStyle.Top));
     toolBar.Text = text;
     return toolBar;
 }
Esempio n. 25
0
        private void toolBarTopicName_ButtonClick(object sender, TD.SandBar.ToolBarItemEventArgs e)
        {
            if (e.Item == buttonItemSave)
            {
                string attribution = (comboBoxAttribution.ComboBox.Text == "") ? comboBoxAttribution.DefaultText : comboBoxAttribution.ComboBox.Text;

                editService.SetTextForTopic((AbsoluteTopicName)listViewTopicNames.SelectedItems[0].Tag, richTextBox1.Text, attribution);

                // reload the version list and refresh the Preview and Text tabs.
                LoadTopic((AbsoluteTopicName)listViewTopicNames.SelectedItems[0].Tag);
            }
            else if (e.Item == buttonItemRestore)
            {
                if (flatComboBoxVersion.SelectedIndex > 0)
                {
                    // restore the topic to a previous version
                    string version = flatComboBoxVersion.SelectedItem.ToString();

                    string attribution = (comboBoxAttribution.ComboBox.Text == "") ? comboBoxAttribution.DefaultText : comboBoxAttribution.ComboBox.Text;
                    editService.RestoreTopic((AbsoluteTopicName)listViewTopicNames.SelectedItems[0].Tag, attribution, version);

                    // reload the version list and refresh the Preview and Text tabs.
                    LoadTopic((AbsoluteTopicName)listViewTopicNames.SelectedItems[0].Tag);
                }
            }
        }
Esempio n. 26
0
        internal void AfterReply(ref ProxyRpc rpc)
        {
            if (!this.isOneWay)
            {
                Message reply = rpc.Reply;

                if (this.deserializeReply)
                {
                    if (TD.ClientFormatterDeserializeReplyStartIsEnabled())
                    {
                        TD.ClientFormatterDeserializeReplyStart(rpc.EventTraceActivity);
                    }

                    bool      outputTiming = DS.MessageFormatterIsEnabled();
                    Stopwatch sw           = null;
                    if (outputTiming)
                    {
                        sw = Stopwatch.StartNew();
                    }

                    rpc.ReturnValue = this.formatter.DeserializeReply(reply, rpc.OutputParameters);

                    if (outputTiming)
                    {
                        DS.ClientMessageFormatterDeserialize(this.formatter.GetType(), sw.Elapsed);
                    }

                    if (TD.ClientFormatterDeserializeReplyStopIsEnabled())
                    {
                        TD.ClientFormatterDeserializeReplyStop(rpc.EventTraceActivity);
                    }
                }
                else
                {
                    rpc.ReturnValue = reply;
                }

                int offset = this.parent.ParameterInspectorCorrelationOffset;
                try
                {
                    bool      outputTiming = DS.ParameterInspectorIsEnabled();
                    Stopwatch sw           = null;
                    if (outputTiming)
                    {
                        sw = new Stopwatch();
                    }

                    for (int i = parameterInspectors.Length - 1; i >= 0; i--)
                    {
                        if (outputTiming)
                        {
                            sw.Restart();
                        }

                        this.parameterInspectors[i].AfterCall(this.name,
                                                              rpc.OutputParameters,
                                                              rpc.ReturnValue,
                                                              rpc.Correlation[offset + i]);
                        if (outputTiming)
                        {
                            DS.ParameterInspectorAfter(this.parameterInspectors[i].GetType(), sw.Elapsed);
                        }

                        if (TD.ClientParameterInspectorAfterCallInvokedIsEnabled())
                        {
                            TD.ClientParameterInspectorAfterCallInvoked(rpc.EventTraceActivity, this.parameterInspectors[i].GetType().FullName);
                        }
                    }
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }
                    if (ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(e))
                    {
                        throw;
                    }
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
                }

                if (parent.ValidateMustUnderstand)
                {
                    Collection <MessageHeaderInfo> headersNotUnderstood = reply.Headers.GetHeadersNotUnderstood();
                    if (headersNotUnderstood != null && headersNotUnderstood.Count > 0)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(SR.GetString(SR.SFxHeaderNotUnderstood, headersNotUnderstood[0].Name, headersNotUnderstood[0].Namespace)));
                    }
                }
            }
        }
Esempio n. 27
0
        void DrawMenu()
        {
            TC_Settings settings = TC_Settings.instance;
            float       width    = 55;

            GUI.color = EditorGUIUtility.isProSkin ? new Color(0.2f, 0.2f, 0.2f) : new Color(0.5f, 0.5f, 0.5f);

            GUI.DrawTexture(new Rect(0, 0, TC_NodeWindow.window.position.width, 20), Texture2D.whiteTexture);
            GUI.color = Color.white;

            EditorGUILayout.BeginHorizontal();
            if (!TC_Settings.instance.hideMenuBar)
            {
                GUILayout.Space(2);
                if (GUILayout.Button("File", EditorStyles.miniButtonMid, GUILayout.Width(width)))
                {
                    GenericMenu menu = new GenericMenu();
                    DrawFile(menu, false);
                    menu.DropDown(new Rect(1, 17, 1, 1));
                }
                if (GUILayout.Button("Options", EditorStyles.miniButtonMid, GUILayout.Width(width)))
                {
                    GenericMenu menu = new GenericMenu();
                    DrawOptions(menu, false);
                    menu.DropDown(new Rect(1 + width, 17, 1, 1));
                }
                if (GUILayout.Button("Help", EditorStyles.miniButtonMid, GUILayout.Width(width)))
                {
                    GenericMenu menu = new GenericMenu();
                    DrawHelp(menu, false);
                    menu.DropDown(new Rect(1 + width * 2, 17, 1, 1));
                }
                if (!TC_Settings.instance.global.documentationClicked)
                {
                    GUI.color = new Color(Mathf.Abs(Mathf.Sin(Time.realtimeSinceStartup)), Mathf.Abs(Mathf.Cos(Time.realtimeSinceStartup)), 0);
                }
                else
                {
                    GUI.color = Color.white;
                }

                if (GUILayout.Button("Documentation", EditorStyles.miniButtonMid, GUILayout.Width(width + 40)))
                {
                    if (Event.current.shift)
                    {
                        TC_Settings.instance.global.documentationClicked = false;
                    }
                    else
                    {
                        TC_Settings.instance.global.documentationClicked = true;
                        Application.OpenURL("http://www.terraincomposer.com/terraincomposer2-documentation/");
                    }
                }
                GUI.color = Color.white;

                GUILayout.Space(TC_NodeWindow.window.position.width - 620 - ((width * 2) + 45));
            }
            else
            {
                GUILayout.Space(TC_NodeWindow.window.position.width - 449 - (width + 5));
            }

            GUI.changed = false;
            float labelWidthOld = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 45;
            settings.seed = EditorGUILayout.FloatField("Seed", settings.seed, GUILayout.Width(100));
            if (GUILayout.Button("Random", EditorStyles.miniButtonMid, GUILayout.Width(50)))
            {
                if (eventCurrent.control)
                {
                    TC_Settings.instance.seed = 0;
                }
                else
                {
                    float oldSeed;
                    do
                    {
                        oldSeed = TC_Settings.instance.seed;
                        TC_Settings.instance.seed = Random.Range(-20000.0f, 20000.0f);
                    }while (oldSeed == TC_Settings.instance.seed);
                }
                GUI.changed = true;
            }
            if (GUI.changed)
            {
                EditorUtility.SetDirty(settings);
                TC.AutoGenerate();
            }
            GUILayout.Space(20);
            EditorGUIUtility.labelWidth = labelWidthOld;

            for (int i = 0; i < 6; i++)
            {
                TC_LayerGroup layerGroup = terrainLayer.layerGroups[i];
                if (layerGroup == null)
                {
                    break;
                }
                if (layerGroup.visible)
                {
                    if (layerGroup.active)
                    {
                        GUI.backgroundColor = Color.green;
                    }
                    else
                    {
                        GUI.backgroundColor = Color.red;
                    }
                }
                if (GUILayout.Button(TC.outputNames[i][0].ToString(), EditorStyles.miniButtonMid, GUILayout.Width(25)))
                {
                    if (eventCurrent.control)
                    {
                        settings.scrollOffset = -layerGroup.nodePos;
                    }
                    else
                    {
                        TD.ClickOutputButton(layerGroup);
                    }
                }
                GUI.backgroundColor = Color.white;
            }
            GUILayout.Space(5);

            if (GUILayout.Button("Generate", EditorStyles.miniButtonMid, GUILayout.Width(width + 5)))
            {
                ClickMenuMain("Generate");
            }
            if (TC_Generate.instance.autoGenerate)
            {
                GUI.backgroundColor = Color.green;
            }
            else if (TC.autoGenerateCallTimeStart + 0.05f > Time.realtimeSinceStartup)
            {
                GUI.backgroundColor = Color.red;
            }
            if (GUILayout.Button("Auto", EditorStyles.miniButtonMid, GUILayout.Width(width)))
            {
                ClickMenuMain("Auto Generate");
            }
            GUI.backgroundColor = Color.white;

            if (GUILayout.Button("Refresh", EditorStyles.miniButtonMid, GUILayout.Width(width)))
            {
                ClickMenuMain("Refresh");
            }

            EditorGUILayout.EndHorizontal();
        }
Esempio n. 28
0
        internal void BeforeRequest(ref ProxyRpc rpc)
        {
            int offset = this.parent.ParameterInspectorCorrelationOffset;

            try
            {
                bool      outputTiming = DS.ParameterInspectorIsEnabled();
                Stopwatch sw           = null;
                if (outputTiming)
                {
                    sw = new Stopwatch();
                }

                for (int i = 0; i < parameterInspectors.Length; i++)
                {
                    if (outputTiming)
                    {
                        sw.Restart();
                    }

                    rpc.Correlation[offset + i] = this.parameterInspectors[i].BeforeCall(this.name, rpc.InputParameters);
                    if (outputTiming)
                    {
                        DS.ParameterInspectorBefore(this.parameterInspectors[i].GetType(), sw.Elapsed);
                    }

                    if (TD.ClientParameterInspectorBeforeCallInvokedIsEnabled())
                    {
                        TD.ClientParameterInspectorBeforeCallInvoked(rpc.EventTraceActivity, this.parameterInspectors[i].GetType().FullName);
                    }
                }
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                if (ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(e))
                {
                    throw;
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
            }

            if (this.serializeRequest)
            {
                if (TD.ClientFormatterSerializeRequestStartIsEnabled())
                {
                    TD.ClientFormatterSerializeRequestStart(rpc.EventTraceActivity);
                }

                bool      outputTiming = DS.MessageFormatterIsEnabled();
                Stopwatch sw           = null;
                if (outputTiming)
                {
                    sw = Stopwatch.StartNew();
                }

                rpc.Request = this.formatter.SerializeRequest(rpc.MessageVersion, rpc.InputParameters);

                if (outputTiming)
                {
                    DS.ClientMessageFormatterSerialize(this.formatter.GetType(), sw.Elapsed);
                }

                if (TD.ClientFormatterSerializeRequestStopIsEnabled())
                {
                    TD.ClientFormatterSerializeRequestStop(rpc.EventTraceActivity);
                }
            }
            else
            {
                if (rpc.InputParameters[0] == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxProxyRuntimeMessageCannotBeNull, this.name)));
                }

                rpc.Request = (Message)rpc.InputParameters[0];
                if (!IsValidAction(rpc.Request, Action))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxInvalidRequestAction, this.Name, rpc.Request.Headers.Action ?? "{NULL}", this.Action)));
                }
            }
        }
Esempio n. 29
0
 private void TextChanged(object sender, TextChangedEventArgs e)
 {
     if (!b_changing)
     {
         b_changing = true;
         TextBox text = sender as TextBox;
         int     i, j;
         int.TryParse(text.Name.Last().ToString(), out j);
         int.TryParse(text.Name[text.Name.Count() - 2].ToString(), out i);
         double TD, d;
         int    fr;
         double ab, bed, eqd2;
         if (j < 3)
         {
             if (last >= 0)
             {
                 if (current != 0 && last != 0)
                 {
                     if (int.TryParse(textFraction[i].Text, out fr))
                     {
                         if (double.TryParse(textDose1fr[i].Text, out d))
                         {
                             if (double.TryParse(textAlphaBeta[i].Text, out ab))
                             {
                                 TD                    = d * fr;
                                 totaldose[i]          = TD / scrollBar.Value * 100;
                                 textTotalDose[i].Text = TD.ToString();
                                 bed                   = TD * (1 + d / ab);
                                 textBED[i].Text       = bed.ToString();
                                 eqd2                  = TD * (d + ab) / (2 + ab);
                                 textEQD2[i].Text      = eqd2.ToString();
                             }
                         }
                     }
                 }
                 else if (current != 1 && last != 1)
                 {
                     if (double.TryParse(textTotalDose[i].Text, out TD))
                     {
                         if (double.TryParse(textDose1fr[i].Text, out d))
                         {
                             if (double.TryParse(textAlphaBeta[i].Text, out ab))
                             {
                                 totaldose[i]         = TD / scrollBar.Value * 100;
                                 fr                   = (int)Math.Round(TD / d);
                                 textFraction[i].Text = fr.ToString();
                                 bed                  = TD * (1 + d / ab);
                                 textBED[i].Text      = bed.ToString();
                                 eqd2                 = TD * (d + ab) / (2 + ab);
                                 textEQD2[i].Text     = eqd2.ToString();
                             }
                         }
                     }
                 }
                 else if (current != 2 && last != 2)
                 {
                     if (double.TryParse(textTotalDose[i].Text, out TD))
                     {
                         if (int.TryParse(textFraction[i].Text, out fr))
                         {
                             if (double.TryParse(textAlphaBeta[i].Text, out ab))
                             {
                                 totaldose[i]        = TD / scrollBar.Value * 100;
                                 d                   = TD / fr;
                                 textDose1fr[i].Text = d.ToString();
                                 bed                 = TD * (1 + d / ab);
                                 textBED[i].Text     = bed.ToString();
                                 eqd2                = TD * (d + ab) / (2 + ab);
                                 textEQD2[i].Text    = eqd2.ToString();
                             }
                         }
                     }
                 }
             }
         }
         if (j == 3)
         {
             if (double.TryParse(textTotalDose[i].Text, out TD))
             {
                 if (int.TryParse(textFraction[i].Text, out fr))
                 {
                     if (double.TryParse(textDose1fr[i].Text, out d))
                     {
                         if (double.TryParse(textAlphaBeta[i].Text, out ab))
                         {
                             TD = totaldose[i] * scrollBar.Value / 100;
                             textTotalDose[i].Text = TD.ToString();
                             d = TD / fr;
                             textDose1fr[i].Text = d.ToString();
                             bed              = TD * (1 + d / ab);
                             textBED[i].Text  = bed.ToString();
                             eqd2             = TD * (d + ab) / (2 + ab);
                             textEQD2[i].Text = eqd2.ToString();
                         }
                     }
                 }
             }
         }
         if (j > 3)
         {
             if (int.TryParse(textFraction[i].Text, out fr))
             {
                 if (double.TryParse(textAlphaBeta[i].Text, out ab))
                 {
                     if (j == 4)
                     {
                         if (double.TryParse(textBED[i].Text, out bed))
                         {
                             d = (-fr + Math.Sqrt(fr * fr + 4 * fr / ab * bed)) / (2 * fr / ab);
                             textDose1fr[i].Text = d.ToString();
                             TD                    = d * fr;
                             totaldose[i]          = TD / scrollBar.Value * 100;
                             textTotalDose[i].Text = TD.ToString();
                             eqd2                  = TD * (d + ab) / (2 + ab);
                             textEQD2[i].Text      = eqd2.ToString();
                         }
                     }
                     if (j == 5)
                     {
                         if (double.TryParse(textEQD2[i].Text, out eqd2))
                         {
                             d = (-fr * ab + Math.Sqrt(fr * ab * fr * ab + 4 * fr * eqd2 * (2 + ab))) / (2 * fr);
                             textDose1fr[i].Text = d.ToString();
                             TD                    = d * fr;
                             totaldose[i]          = TD / scrollBar.Value * 100;
                             textTotalDose[i].Text = TD.ToString();
                             bed                   = TD * (1 + d / ab);
                             textBED[i].Text       = bed.ToString();
                         }
                     }
                 }
             }
         }
         Sum();
         b_changing = false;
     }
 }
        public void ObjectValue(TD d)
        {
            CollectionAssert.IsNotEmpty(d.JSON);
            object o = JsonConvert.DeserializeObject(d.JSON, d.Type, _jss);
            Assert.IsNotNull(o);

            foreach(string k in d.Expected.Keys)
            {
                PropertyInfo p = p = d.Type.GetProperty(k, BindingFlags.Public | BindingFlags.Instance);
                Assert.IsNotNull(p);
                Assert.IsTrue(p.CanRead);

                object v = p.GetValue(o);
                Assert.AreEqual(d.Expected[k], v);
            }
        }
        void DeserializeInputs(ref MessageRpc rpc)
        {
            bool success = false;

            try
            {
                try
                {
                    rpc.InputParameters = this.Invoker.AllocateInputs();
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }
                    if (ErrorBehavior.ShouldRethrowExceptionAsIs(e))
                    {
                        throw;
                    }
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
                }
                try
                {
                    // If the field is true, then this operation is to be invoked at the time the service
                    // channel is opened. The incoming message is created at ChannelHandler level with no
                    // content, so we don't need to deserialize the message.
                    if (!this.isSessionOpenNotificationEnabled)
                    {
                        if (this.deserializeRequest)
                        {
                            if (TD.DispatchFormatterDeserializeRequestStartIsEnabled())
                            {
                                TD.DispatchFormatterDeserializeRequestStart(rpc.EventTraceActivity);
                            }

                            bool      outputTiming = DS.MessageFormatterIsEnabled();
                            Stopwatch sw           = null;
                            if (outputTiming)
                            {
                                sw = Stopwatch.StartNew();
                            }

                            this.Formatter.DeserializeRequest(rpc.Request, rpc.InputParameters);

                            if (outputTiming)
                            {
                                DS.DispatchMessageFormatterDeserialize(this.Formatter.GetType(), sw.Elapsed);
                            }

                            if (TD.DispatchFormatterDeserializeRequestStopIsEnabled())
                            {
                                TD.DispatchFormatterDeserializeRequestStop(rpc.EventTraceActivity);
                            }
                        }
                        else
                        {
                            rpc.InputParameters[0] = rpc.Request;
                        }
                    }

                    success = true;
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }
                    if (ErrorBehavior.ShouldRethrowExceptionAsIs(e))
                    {
                        throw;
                    }
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
                }
            }
            finally
            {
                rpc.DidDeserializeRequestBody = (rpc.Request.State != MessageState.Created);

                if (!success && MessageLogger.LoggingEnabled)
                {
                    MessageLogger.LogMessage(ref rpc.Request, MessageLoggingSource.Malformed);
                }
            }
        }
Esempio n. 32
0
        private async Task <Tuple <object, object[]> > InvokeAsync(object instance, object[] inputs)
        {
            EnsureIsInitialized();

            if (instance == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new InvalidOperationException(SR.SFxNoServiceObject));
            }
            if (inputs == null)
            {
                if (_inputParameterCount > 0)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                              new InvalidOperationException(SR.Format(SR.SFxInputParametersToServiceNull, _inputParameterCount)));
                }
            }
            else if (inputs.Length != _inputParameterCount)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new InvalidOperationException(SR.Format(SR.SFxInputParametersToServiceInvalid, _inputParameterCount,
                                                                  inputs.Length)));
            }

            var outputs = EmptyArray <object> .Allocate(_outputParameterCount);

            long beginOperation = 0;
            bool callSucceeded  = false;
            bool callFaulted    = false;

            EventTraceActivity eventTraceActivity = null;

            if (TD.OperationCompletedIsEnabled() ||
                TD.OperationFaultedIsEnabled() ||
                TD.OperationFailedIsEnabled())
            {
                beginOperation = DateTime.UtcNow.Ticks;
                OperationContext context = OperationContext.Current;
                if (context != null && context.IncomingMessage != null)
                {
                    eventTraceActivity = EventTraceActivityHelper.TryExtractActivity(context.IncomingMessage);
                }
            }

            object returnValue;

            try
            {
                ServiceModelActivity activity      = null;
                IDisposable          boundActivity = null;
                if (DiagnosticUtility.ShouldUseActivity)
                {
                    activity      = ServiceModelActivity.CreateBoundedActivity(true);
                    boundActivity = activity;
                }
                else if (TraceUtility.MessageFlowTracingOnly)
                {
                    Guid activityId = TraceUtility.GetReceivedActivityId(OperationContext.Current);
                    if (activityId != Guid.Empty)
                    {
                        DiagnosticTraceBase.ActivityId = activityId;
                    }
                }
                else if (TraceUtility.ShouldPropagateActivity)
                {
                    //Message flow tracing only scenarios use a light-weight ActivityID management logic
                    Guid activityId = ActivityIdHeader.ExtractActivityId(OperationContext.Current.IncomingMessage);
                    if (activityId != Guid.Empty)
                    {
                        boundActivity = Activity.CreateActivity(activityId);
                    }
                }

                using (boundActivity)
                {
                    if (DiagnosticUtility.ShouldUseActivity)
                    {
                        ServiceModelActivity.Start(activity,
                                                   SR.Format(SR.ActivityExecuteMethod, _taskMethod.DeclaringType.FullName, _taskMethod.Name),
                                                   ActivityType.ExecuteUserCode);
                    }
                    if (TD.OperationInvokedIsEnabled())
                    {
                        TD.OperationInvoked(eventTraceActivity, MethodName,
                                            TraceUtility.GetCallerInfo(OperationContext.Current));
                    }
                    returnValue = _invokeDelegate(instance, inputs, outputs);

                    if (returnValue == null)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("task");
                    }

                    var returnValueTask = returnValue as Task;
                    if (returnValueTask != null)
                    {
                        // Only return once the task has completed
                        await returnValueTask;
                    }

                    callSucceeded = true;
                }
            }
            catch (FaultException)
            {
                callFaulted = true;
                throw;
            }
            finally
            {
                if (beginOperation != 0)
                {
                    if (callSucceeded)
                    {
                        if (TD.OperationCompletedIsEnabled())
                        {
                            TD.OperationCompleted(eventTraceActivity, _methodName,
                                                  TraceUtility.GetUtcBasedDurationForTrace(beginOperation));
                        }
                    }
                    else if (callFaulted)
                    {
                        if (TD.OperationFaultedIsEnabled())
                        {
                            TD.OperationFaulted(eventTraceActivity, _methodName,
                                                TraceUtility.GetUtcBasedDurationForTrace(beginOperation));
                        }
                    }
                    else
                    {
                        if (TD.OperationFailedIsEnabled())
                        {
                            TD.OperationFailed(eventTraceActivity, _methodName,
                                               TraceUtility.GetUtcBasedDurationForTrace(beginOperation));
                        }
                    }
                }
            }

            return(Tuple.Create(returnValue, outputs));
        }
            internal Message MarshalMessage(Message source, Uri to, MessageVersion targetVersion)
            {
                Message           result;
                MessageHeaders    sourceHeaders        = source.Headers;
                MessageVersion    sourceVersion        = source.Version;
                UnderstoodHeaders understoodHeaders    = sourceHeaders.UnderstoodHeaders;
                HashSet <string>  understoodHeadersSet = CreateKeys(understoodHeaders);

#if DEBUG_MARSHALING
                System.Text.StringBuilder details = new System.Text.StringBuilder();
                details.AppendFormat("Original Message:\r\n{0}\r\n", source);
                details.AppendLine("Understood Headers:");
                foreach (MessageHeaderInfo understoodHeader in understoodHeaders)
                {
                    details.AppendFormat("\t{0}\t({1})\r\n", understoodHeader.Name, understoodHeader.Namespace);
                }
                details.AppendLine("Properties:");
                foreach (KeyValuePair <string, object> item in source.Properties)
                {
                    details.AppendFormat("\t{0}\t({1})\r\n", item.Key, item.Value);
                }
#endif //DEBUG_MARSHALING


                //if we've understood and verified the security of the message, we need to create a new message
                if (sourceVersion == targetVersion && !RoutingUtilities.IsMessageUsingWSSecurity(understoodHeaders))
                {
                    FilterHeaders(sourceHeaders, understoodHeadersSet);
                    FilterProperties(source.Properties);
                    result = source;
                }
                else
                {
                    if (source.IsFault)
                    {
                        MessageFault messageFault = MessageFault.CreateFault(source, int.MaxValue);
                        string       action       = sourceHeaders.Action;
                        if (string.Equals(action, sourceVersion.Addressing.DefaultFaultAction, StringComparison.Ordinal))
                        {
                            //The action was the default for the sourceVersion set it to the default for the targetVersion.
                            action = targetVersion.Addressing.DefaultFaultAction;
                        }
                        result = Message.CreateMessage(targetVersion, messageFault, action);
                    }
                    else if (source.IsEmpty)
                    {
                        result = Message.CreateMessage(targetVersion, sourceHeaders.Action);
                    }
                    else
                    {
                        XmlDictionaryReader bodyReader = source.GetReaderAtBodyContents();
                        result = Message.CreateMessage(targetVersion, sourceHeaders.Action, bodyReader);
                    }

                    CloneHeaders(result.Headers, sourceHeaders, to, understoodHeadersSet);
                    CloneProperties(result.Properties, source.Properties);
                }

#if DEBUG_MARSHALING
                details.AppendFormat("\r\nMarshaled Message:\r\n{0}\r\n", result);
                details.AppendLine("Properties:");
                foreach (KeyValuePair <string, object> item in result.Properties)
                {
                    details.AppendFormat("\t{0}\t({1})\r\n", item.Key, item.Value);
                }
                System.Diagnostics.Trace.WriteLine(details);
                TD.RoutingServiceDisplayConfig(details.ToString(), "");
#endif //DEBUG_MARSHALING

                return(result);
            }
Esempio n. 34
0
        public void DrawCustomInspector()
        {
            TC_GlobalSettings globalSettings = TC_Settings.instance.global;

            serializedObject.Update();
            global.Update();

            TD.DrawSpacer();
            TD.DrawLabelWidthUnderline("Local Settings", 14);

            EditorGUILayout.BeginVertical("Box");

            GUILayout.Space(5);

            TD.DrawProperty(masterTerrain, new GUIContent("Master Terrain", globalSettings.tooltip ? "This terrain is used for selecting the splat textures, grass textures and trees in the nodes." : ""));

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(new GUIContent("Node Preview Image Resolution", globalSettings.tooltip ? "The resolution of the node preview images." : ""));
            previewResolution.intValue = EditorGUILayout.IntPopup(previewResolution.intValue, previewResolutionsDisplay, previewResolutions);
            EditorGUILayout.EndHorizontal();

            TD.DrawProperty(hideTerrainGroup, new GUIContent("Hide TerrainLayer GameObject"));
            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
                TC_NodeWindow.DebugMode();
            }

            EditorGUILayout.EndVertical();

            GUILayout.Space(10);
            TD.DrawSpacer();
            GUILayout.Space(10);

            TD.DrawLabelWidthUnderline("Global Settings", 14);
            GUILayout.Space(5);

            EditorGUILayout.BeginVertical("Box");
            TD.DrawProperty(tooltip);

            GUI.changed = false;
            Vector3 defaultTerrainSize = globalSettings.defaultTerrainSize;

            defaultTerrainSize = EditorGUILayout.Vector3Field("Default Node Size", defaultTerrainSize);
            if (GUI.changed)
            {
                Undo.RecordObject(globalSettings, "Default Terrain Size");
                globalSettings.defaultTerrainSize = defaultTerrainSize;
                EditorUtility.SetDirty(globalSettings);
            }
            EditorGUILayout.EndVertical();

            GUILayout.Space(5);

            TD.DrawLabelWidthUnderline("Keys", 12);

            EditorGUILayout.BeginVertical("Box");
            TD.DrawProperty(keyZoomIn);
            TD.DrawProperty(keyZoomOut);
            EditorGUILayout.EndVertical();

            TD.DrawLabelWidthUnderline("Node Colors", 12);

            EditorGUILayout.BeginVertical("Box");

            TD.DrawProperty(colLayerGroup, new GUIContent("Color Layer Group"));
            TD.DrawProperty(colLayer, new GUIContent("Color Layer"));
            TD.DrawProperty(colMaskNodeGroup, new GUIContent("Color Mask Node Group"));
            TD.DrawProperty(colMaskNode, new GUIContent("Color Mask Node"));
            TD.DrawProperty(colSelectNodeGroup, new GUIContent("Color Select Node Group"));
            TD.DrawProperty(colSelectNode, new GUIContent("Color Select Node"));
            TD.DrawProperty(colSelectItemGroup, new GUIContent("Color Select Item Group"));
            TD.DrawProperty(colSelectItem, new GUIContent("Color Select Item"));

            EditorGUILayout.EndVertical();

            GUILayout.Space(5);

            TD.DrawPropertyArray(previewColors);

            TD.DrawSpacer();

            serializedObject.ApplyModifiedProperties();
            global.ApplyModifiedProperties();
        }
Esempio n. 35
0
        internal void AfterReply(ref ProxyRpc rpc)
        {
            if (!_isOneWay)
            {
                Message reply = rpc.Reply;

                if (_deserializeReply)
                {
                    if (TD.ClientFormatterDeserializeReplyStartIsEnabled())
                    {
                        TD.ClientFormatterDeserializeReplyStart(rpc.EventTraceActivity);
                    }

                    rpc.ReturnValue = _formatter.DeserializeReply(reply, rpc.OutputParameters);

                    if (TD.ClientFormatterDeserializeReplyStopIsEnabled())
                    {
                        TD.ClientFormatterDeserializeReplyStop(rpc.EventTraceActivity);
                    }
                }
                else
                {
                    rpc.ReturnValue = reply;
                }

                int offset = _parent.ParameterInspectorCorrelationOffset;
                try
                {
                    for (int i = _parameterInspectors.Length - 1; i >= 0; i--)
                    {
                        _parameterInspectors[i].AfterCall(_name,
                                                          rpc.OutputParameters,
                                                          rpc.ReturnValue,
                                                          rpc.Correlation[offset + i]);
                        if (TD.ClientParameterInspectorAfterCallInvokedIsEnabled())
                        {
                            TD.ClientParameterInspectorAfterCallInvoked(rpc.EventTraceActivity, _parameterInspectors[i].GetType().FullName);
                        }
                    }
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }
                    if (ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(e))
                    {
                        throw;
                    }
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
                }

                if (_parent.ValidateMustUnderstand)
                {
                    Collection <MessageHeaderInfo> headersNotUnderstood = reply.Headers.GetHeadersNotUnderstood();
                    if (headersNotUnderstood != null && headersNotUnderstood.Count > 0)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(SR.Format(SR.SFxHeaderNotUnderstood, headersNotUnderstood[0].Name, headersNotUnderstood[0].Namespace)));
                    }
                }
            }
        }
 void DrawCustomInspector()
 {
     TD.DrawSpacer();
     TD.DrawLabel("This script is needed for generating on the GPU", 12);
     TD.DrawSpacer();
 }
Esempio n. 37
0
        protected override SecurityToken VerifySignature(SignedXml signedXml, bool isPrimarySignature,
                                                         SecurityHeaderTokenResolver resolver, object signatureTarget, string id)
        {
            if (TD.SignatureVerificationStartIsEnabled())
            {
                TD.SignatureVerificationStart(this.EventTraceActivity);
            }

            SecurityToken token = ResolveSignatureToken(signedXml.Signature.KeyIdentifier, resolver, isPrimarySignature);

            if (isPrimarySignature)
            {
                RecordSignatureToken(token);
            }
            ReadOnlyCollection <SecurityKey> keys = token.SecurityKeys;
            SecurityKey securityKey = (keys != null && keys.Count > 0) ? keys[0] : null;

            if (securityKey == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(
                                                                              SR.GetString(SR.UnableToCreateICryptoFromTokenForSignatureVerification, token)));
            }
            this.AlgorithmSuite.EnsureAcceptableSignatureKeySize(securityKey, token);
            this.AlgorithmSuite.EnsureAcceptableSignatureAlgorithm(securityKey, signedXml.Signature.SignedInfo.SignatureMethod);
            signedXml.StartSignatureVerification(securityKey);
            StandardSignedInfo signedInfo = (StandardSignedInfo)signedXml.Signature.SignedInfo;

            ValidateDigestsOfTargetsInSecurityHeader(signedInfo, this.Timestamp, isPrimarySignature, signatureTarget, id);

            if (!isPrimarySignature)
            {
                if ((!this.RequireMessageProtection) && (securityKey is AsymmetricSecurityKey) && (this.Version.Addressing != AddressingVersion.None))
                {
                    // For Transport Security using Asymmetric Keys verify that
                    // the 'To' header is signed.
                    int headerIndex = this.Message.Headers.FindHeader(XD.AddressingDictionary.To.Value, this.Message.Version.Addressing.Namespace);
                    if (headerIndex == -1)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(SR.GetString(SR.TransportSecuredMessageMissingToHeader)));
                    }
                    XmlDictionaryReader toHeaderReader = this.Message.Headers.GetReaderAtHeader(headerIndex);
                    id = toHeaderReader.GetAttribute(XD.UtilityDictionary.IdAttribute, XD.UtilityDictionary.Namespace);

                    // DevDiv:938534 - We added a flag that allow unsigned headers. If this is set, we do not throw an Exception but move on to CompleteSignatureVerification()
                    if (LocalAppContextSwitches.AllowUnsignedToHeader)
                    {
                        // The lack of an id indicates that the sender did not wish to sign the header. We can safely assume that null indicates this header is not signed.
                        // If id is not null, then we need to validate the Digest and ensure signature is valid. The exception is thrown deeper in the System.IdentityModel stack.
                        if (id != null)
                        {
                            signedXml.EnsureDigestValidityIfIdMatches(id, toHeaderReader);
                        }
                    }
                    else
                    {
                        // default behavior for all platforms
                        if (id == null)
                        {
                            //
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(SR.GetString(SR.UnsignedToHeaderInTransportSecuredMessage)));
                        }
                        signedXml.EnsureDigestValidity(id, toHeaderReader);
                    }
                }
                signedXml.CompleteSignatureVerification();
                return(token);
            }
            this.pendingSignature = signedXml;

            if (TD.SignatureVerificationSuccessIsEnabled())
            {
                TD.SignatureVerificationSuccess(this.EventTraceActivity);
            }

            return(token);
        }
Esempio n. 38
0
 public TC GetContent(TD data)
 {
     return(getRowElementFunc(data));
 }
Esempio n. 39
0
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
        {
            object obj2;

            if (instance == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxNoServiceObject")));
            }
            outputs = EmptyArray.Allocate(this.OutputParameterCount);
            bool flag  = true;
            bool flag2 = false;

            try
            {
                ServiceModelActivity activity       = null;
                Activity             boundOperation = null;
                this.GetActivityInfo(ref activity, ref boundOperation);
                using (boundOperation)
                {
                    obj2 = this.InvokeEndDelegate(instance, outputs, result);
                    flag = false;
                }
                ServiceModelActivity.Stop(activity);
            }
            catch (SecurityException exception)
            {
                DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning);
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(AuthorizationBehavior.CreateAccessDeniedFaultException());
            }
            catch (FaultException)
            {
                flag2 = true;
                flag  = false;
                throw;
            }
            finally
            {
                if (flag)
                {
                    if (TD.OperationFailedIsEnabled())
                    {
                        TD.OperationFailed(this.EndMethod.Name, TraceUtility.GetUtcBasedDurationForTrace(TraceUtility.ExtractAsyncOperationStartTime()));
                    }
                }
                else if (flag2)
                {
                    if (TD.OperationFaultedIsEnabled())
                    {
                        TD.OperationFaulted(this.EndMethod.Name, TraceUtility.GetUtcBasedDurationForTrace(TraceUtility.ExtractAsyncOperationStartTime()));
                    }
                }
                else if (TD.OperationCompletedIsEnabled())
                {
                    TD.OperationCompleted(this.EndMethod.Name, TraceUtility.GetUtcBasedDurationForTrace(TraceUtility.ExtractAsyncOperationStartTime()));
                }
                if (PerformanceCounters.PerformanceCountersEnabled)
                {
                    if (flag)
                    {
                        PerformanceCounters.MethodReturnedError(this.endMethod.Name.Substring("End".Length));
                    }
                    else if (flag2)
                    {
                        PerformanceCounters.MethodReturnedFault(this.endMethod.Name.Substring("End".Length));
                    }
                    else
                    {
                        PerformanceCounters.MethodReturnedSuccess(this.endMethod.Name.Substring("End".Length));
                    }
                }
            }
            return(obj2);
        }
Esempio n. 40
0
 internal Row(ref TD data, IEnumerable <Column> cells)
 {
     this.cells = cells;
     this.data  = data;
 }
Esempio n. 41
0
        static public void ClickMenuInput(object obj)
        {
            int    instanceID;
            string command = TD.ObjectToCommandAndInstanceID(obj, out instanceID);

            TC_Node node = EditorUtility.InstanceIDToObject(instanceID) as TC_Node;

            if (node != null)
            {
                int    index     = command.IndexOf("/");
                string inputKind = command.Substring(0, index);
                string input     = command.Substring(index + 1);
                bool   changed   = false;

                InputKind oldInputKind = node.inputKind;
                node.inputKind = (InputKind)Enum.Parse(typeof(InputKind), inputKind);

                if (node.inputKind != oldInputKind)
                {
                    changed = true;
                }

                if (inputKind == "Terrain")
                {
                    InputTerrain oldInputTerrain = node.inputTerrain;
                    node.inputTerrain = (InputTerrain)Enum.Parse(typeof(InputTerrain), input);
                    if (node.inputTerrain != oldInputTerrain)
                    {
                        changed = true;
                    }
                }
                else if (inputKind == "Noise")
                {
                    InputNoise oldInputNoise = node.inputNoise;
                    node.inputNoise = (InputNoise)Enum.Parse(typeof(InputNoise), input);
                    if (node.inputNoise != oldInputNoise)
                    {
                        changed = true;
                    }
                }
                else if (inputKind == "Shape")
                {
                    InputShape oldInputShape = node.inputShape;
                    node.inputShape = (InputShape)Enum.Parse(typeof(InputShape), input);
                    if (node.inputShape != oldInputShape)
                    {
                        changed = true;
                    }
                }
                else if (inputKind == "File")
                {
                    InputFile oldInputFile = node.inputFile;
                    node.inputFile = (InputFile)Enum.Parse(typeof(InputFile), input);
                    if (node.inputFile != oldInputFile)
                    {
                        changed = true;
                    }
                }
                else if (inputKind == "Current")
                {
                    InputCurrent oldInputCurrent = node.inputCurrent;
                    node.inputCurrent = (InputCurrent)Enum.Parse(typeof(InputCurrent), input);
                    if (node.inputCurrent != oldInputCurrent)
                    {
                        changed = true;
                    }
                }
                else if (inputKind == "Portal")
                {
                    InputPortal oldInputPortal = node.inputPortal;
                    node.inputPortal = (InputPortal)Enum.Parse(typeof(InputPortal), input);
                    if (node.inputPortal != oldInputPortal)
                    {
                        changed = true;
                    }
                }

                if (changed)
                {
                    node.Init();
                    EditorUtility.SetDirty(node);
                    TC.RefreshOutputReferences(node.outputId, true);
                }
            }
        }
Esempio n. 42
0
		private void sandDockManager1_DockControlClosing(object sender, TD.SandDock.DockControlClosingEventArgs e)
		{
			// If this is a tabbed document, prompt to save changes
			if (e.DockControl is TabbedDocument)
			{
				DialogResult result = MessageBox.Show(this, "Do you wish to save changes made to " + e.DockControl.Text + "?", "Close Document", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
				if (result == DialogResult.Cancel)
					e.Cancel = true;
			}
		}
Esempio n. 43
0
        // This method should only be called when we relinquished the thread but did not
        // complete the operation (silent yield is the current example)
        public void InternalResume(RequestedAction action)
        {
            Fx.Assert(_isRunning, "We should still be processing work - we just don't have a thread");

            bool isTracingEnabled   = CoreWf.Internals.FxTrace.ShouldTraceInformation;
            bool notifiedCompletion = false;
            bool isInstanceComplete = false;

            if (_callbacks.IsAbortPending)
            {
                _isPausing = false;
                _isRunning = false;

                this.NotifyWorkCompletion();
                notifiedCompletion = true;

                if (isTracingEnabled)
                {
                    isInstanceComplete = _callbacks.IsCompleted;
                }

                // After calling SchedulerIdle we no longer have the lock.  That means
                // that any subsequent processing in this method won't have the single
                // threaded guarantee.
                _callbacks.SchedulerIdle();
            }
            else if (object.ReferenceEquals(action, s_continueAction))
            {
                ScheduleWork(false);
            }
            else
            {
                Fx.Assert(action is NotifyUnhandledExceptionAction, "This is the only other choice because we should never have YieldSilently here");

                NotifyUnhandledExceptionAction notifyAction = (NotifyUnhandledExceptionAction)action;

                // We only set isRunning back to false so that the host doesn't
                // have to treat this like a pause notification.  As an example,
                // a host could turn around and call run again in response to
                // UnhandledException without having to go through its operation
                // dispatch loop first (or request pause again).  If we reset
                // isPausing here then any outstanding operations wouldn't get
                // signaled with that type of host.
                _isRunning = false;

                this.NotifyWorkCompletion();
                notifiedCompletion = true;

                if (isTracingEnabled)
                {
                    isInstanceComplete = _callbacks.IsCompleted;
                }

                _callbacks.NotifyUnhandledException(notifyAction.Exception, notifyAction.Source);
            }

            if (isTracingEnabled)
            {
                if (notifiedCompletion)
                {
                    Guid oldActivityId = Guid.Empty;
                    bool resetId       = false;

                    if (isInstanceComplete)
                    {
                        if (TD.WorkflowActivityStopIsEnabled())
                        {
                            TD.SetActivityId(_callbacks.WorkflowInstanceId, out oldActivityId);
                            resetId = true;

                            TD.WorkflowActivityStop(_callbacks.WorkflowInstanceId);
                        }
                    }
                    else
                    {
                        if (TD.WorkflowActivitySuspendIsEnabled())
                        {
                            TD.SetActivityId(_callbacks.WorkflowInstanceId, out oldActivityId);
                            resetId = true;

                            TD.WorkflowActivitySuspend(_callbacks.WorkflowInstanceId);
                        }
                    }

                    if (resetId)
                    {
                        TD.CurrentActivityId = oldActivityId;
                    }
                }
            }
        }
Esempio n. 44
0
		private void sandDockManager1_ShowControlContextMenu(object sender, TD.SandDock.ShowControlContextMenuEventArgs e)
		{
			ctxWindow.Show(e.DockControl, e.Position);
		}
Esempio n. 45
0
 /// <summary>
 /// Update main user interface.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Events_Closing(object sender, TD.SandDock.DockControlClosingEventArgs e)
 {
     this.ApplicationForm.CloseEventViewer();
 }
Esempio n. 46
0
		private void sandDockManager1_DockControlRemoved(object sender, TD.SandDock.DockControlEventArgs e)
		{
			AppendLog("DockControl Removed: " + e.DockControl.Text);
		}
        private void MenuItem_BeforePopup(object sender, TD.SandBar.MenuPopupEventArgs e) {
            try {
                // Get Schema and ActiveModel
                SchemaModel schemaModel = null;
                EsriModel activeModel = null;
                DockControl[] dockControls = this.sandDockManager1.GetDockControls(DockSituation.Document);
                TabbedDocument activeTab = null;
                if (dockControls.Length > 0) {
                    foreach (TabbedDocument tab2 in dockControls) {
                        if (tab2 is ITabModel) {
                            ITabModel tabModel = (ITabModel)tab2;
                            if (tabModel.Model.GetType() == typeof(SchemaModel)) {
                                schemaModel = (SchemaModel)tabModel.Model;
                                break;
                            }
                        }
                    }
                    activeTab = this.sandDockManager1.ActiveTabbedDocument as TabbedDocument;
                    if (activeTab is ITabModel) {
                        ITabModel tabModel = (ITabModel)activeTab;
                        activeModel = tabModel.Model;
                    }
                }

                if (sender == this.menuBarItemFile) {
                    this.menuButtonItemNew.Enabled = true;
                    this.menuButtonItemOpen.Enabled = true;
                    this.menuButtonItemClose.Enabled = (schemaModel != null);
                    this.menuButtonItemSave.Enabled = (schemaModel != null);
                    this.menuButtonItemSaveAs.Enabled = (schemaModel != null);
                    this.menuButtonItemPublish.Enabled = (schemaModel != null);
                    this.menuButtonItemExport.Enabled = (dockControls.Length != 0);
                    this.menuButtonItemPrintSetup.Enabled = (activeTab != null && (activeTab is ITabModel || activeTab is ITabPrinter));
                    this.menuButtonItemPrint.Enabled = (dockControls.Length != 0);
                    this.menuButtonItemPrintPreview.Enabled = (dockControls.Length != 0);
                    this.menuButtonItemExit.Enabled = true;

                    string save = (schemaModel == null) ? string.Empty : schemaModel.Title;
                    this.menuButtonItemSave.Text = string.Format(Resources.TEXT_SAVE_, save);
                    this.menuButtonItemSaveAs.Text = string.Format(Resources.TEXT_SAVE_AS_, save);
                }
                else if (sender == this.menuBarItemEdit) {
                    bool cut = (activeModel != null) && (activeModel.CanCut);
                    bool copy = (activeModel != null) && (activeModel.CanCopy);
                    bool paste = (activeModel != null) && (activeModel.CanPaste);
                    bool delete = (activeModel != null) && (activeModel.CanDelete);
                    bool undo = (activeModel != null) && (activeModel.CanUndo);
                    bool redo = (activeModel != null) && (activeModel.CanRedo);
                    bool selectAll = (activeModel != null) && (activeModel.CanSelectAll);

                    this.menuButtonItemCut.Enabled = cut;
                    this.menuButtonItemCopy.Enabled = copy;
                    this.menuButtonItemPaste.Enabled = paste;
                    this.menuButtonItemDelete.Enabled = delete;
                    this.menuButtonItemSelectAll.Enabled = selectAll;
                    this.menuButtonItemUndo.Enabled = undo;
                    this.menuButtonItemRedo.Enabled = redo;
                }
                else if (sender == this.menuBarItemView) {
                    this.menuButtonItemColorScheme.Enabled = true;
                    this.menuButtonItemLayout.Enabled = true;
                    this.menuButtonItemToolbars.Enabled = true;
                    this.menuButtonItemZoom.Enabled = true;
                    this.menuButtonItemExceptions.Enabled = true;
                    this.menuButtonItemStatusBar.Enabled = true;
                    this.menuButtonItemOverviewWindow.Enabled = true;
                    this.menuButtonItemCatalogWindow.Enabled = true;
                    this.menuButtonItemPaletteWindow.Enabled = true;
                    this.menuButtonItemPropertiesWindow.Enabled = true;
                    this.menuButtonItemErrorList.Enabled = true;

                    this.menuButtonItemOverviewWindow.Checked = (this.dockableWindowOverview.IsOpen || this.dockableWindowOverview.DockSituation == DockSituation.Docked);
                    this.menuButtonItemCatalogWindow.Checked = (this.dockableWindowCatalog.IsOpen || this.dockableWindowCatalog.DockSituation == DockSituation.Docked);
                    this.menuButtonItemPaletteWindow.Checked = (this.dockableWindowPalette.IsOpen || this.dockableWindowPalette.DockSituation == DockSituation.Docked);
                    this.menuButtonItemPropertiesWindow.Checked = (this.dockableWindowProperties.IsOpen || this.dockableWindowProperties.DockSituation == DockSituation.Docked);
                    this.menuButtonItemErrorList.Checked = (this.dockableWindowErrorList.IsOpen || this.dockableWindowErrorList.DockSituation == DockSituation.Docked);
                    this.menuButtonItemStatusBar.Checked = this.statusBar1.Visible;
                }
                else if (sender == this.menuButtonItemColorScheme) {
                    this.menuButtonItemColorSchemeBlack.Checked = (ColorSchemeSettings.Default.ColorScheme == Office2007ColorScheme.Black);
                    this.menuButtonItemColorSchemeBlue.Checked = (ColorSchemeSettings.Default.ColorScheme == Office2007ColorScheme.Blue);
                    this.menuButtonItemColorSchemeSilver.Checked = (ColorSchemeSettings.Default.ColorScheme == Office2007ColorScheme.Silver);
                }
                else if (sender == this.menuButtonItemLayout) {
                    bool hasActiveModel = activeModel != null;
                    bool hasSelectedShapes = hasActiveModel && activeModel.SelectedShapes().Count > 1;

                    this.menuButtonItemCircular.Enabled = hasActiveModel;
                    this.menuButtonItemForcedDirect.Enabled = hasActiveModel;
                    this.menuButtonItemHierachical.Enabled = hasActiveModel;
                    this.menuButtonItemOrthogonal.Enabled = hasActiveModel;
                    this.menuButtonItemTree.Enabled = hasActiveModel;

                    this.menuButtonItemAlignLeft.Enabled = hasSelectedShapes;
                    this.menuButtonItemAlignCenter.Enabled = hasSelectedShapes;
                    this.menuButtonItemAlignRight.Enabled = hasSelectedShapes;
                    this.menuButtonItemAlignTop.Enabled = hasSelectedShapes;
                    this.menuButtonItemAlignMiddle.Enabled = hasSelectedShapes;
                    this.menuButtonItemAlignBottom.Enabled = hasSelectedShapes;
                }
                else if (sender == this.menuButtonItemToolbars) {
                    this.menuButtonItemStandardToolbar.Enabled = true;
                    this.menuButtonItemLayoutToolbar.Enabled = true;
                    this.menuButtonItemInteractiveModeToolbar.Enabled = true;

                    this.menuButtonItemStandardToolbar.Checked = (this.toolBarStandard.Visible);
                    this.menuButtonItemLayoutToolbar.Checked = (this.toolBarLayout.Visible);
                    this.menuButtonItemInteractiveModeToolbar.Checked = (this.toolBarInteractiveMode.Visible);
                }
                else if (sender == this.menuButtonItemZoom) {
                    this.menuButtonItemZoom300.Enabled = (activeModel != null);
                    this.menuButtonItemZoom200.Enabled = (activeModel != null);
                    this.menuButtonItemZoom100.Enabled = (activeModel != null);
                    this.menuButtonItemZoom75.Enabled = (activeModel != null);
                    this.menuButtonItemZoom50.Enabled = (activeModel != null);
                    this.menuButtonItemZoom25.Enabled = (activeModel != null);
                    this.menuButtonItemZoomFull.Enabled = (activeModel != null);

                    this.menuButtonItemZoom300.Checked = (activeModel != null && activeModel.Zoom == 300f);
                    this.menuButtonItemZoom200.Checked = (activeModel != null && activeModel.Zoom == 200f);
                    this.menuButtonItemZoom100.Checked = (activeModel != null && activeModel.Zoom == 100f);
                    this.menuButtonItemZoom75.Checked = (activeModel != null && activeModel.Zoom == 75f);
                    this.menuButtonItemZoom50.Checked = (activeModel != null && activeModel.Zoom == 50f);
                    this.menuButtonItemZoom25.Checked = (activeModel != null && activeModel.Zoom == 25f);
                    this.menuButtonItemZoomFull.Checked = false;
                }
                else if (sender == this.menuBarItemTools) {
                    this.menuButtonItemNormalMode.Enabled = (activeModel != null);
                    this.menuButtonItemLinkMode.Enabled = (activeModel != null);
                    this.menuButtonItemSchemaReport.Enabled = true;
                    this.menuButtonItemDataReport.Enabled = true;
                    this.menuButtonItemValidate.Enabled = (schemaModel != null);
                    this.menuButtonItemOptions.Enabled = true;
                    this.menuButtonItemNormalMode.Checked = (activeModel != null && activeModel.Runtime.InteractiveMode == InteractiveMode.Normal);
                    this.menuButtonItemLinkMode.Checked = (activeModel != null && activeModel.Runtime.InteractiveMode == InteractiveMode.AddLine);
                }
                else if (sender == this.menuBarItemWindow) {
                    this.menuButtonItemNewHorizontalTabGroup.Enabled = (dockControls.Length > 1);
                    this.menuButtonItemNewVerticalTabGroup.Enabled = (dockControls.Length > 1);
                    this.menuButtonItemRestoreTabGroup.Enabled = (dockControls.Length > 1);
                    this.menuButtonItemCloseAllDocuments.Enabled = (dockControls.Length > 0);
                    this.menuButtonItemWindows.Enabled = (dockControls.Length > 0);
                }
                else if (sender == this.menuBarItemHelp) {
                    this.menuButtonItemUserGuide.Enabled = true;
                    this.menuButtonItemSendFeedback.Enabled = true;
                    this.menuButtonItemEsriHome.Enabled = true;
                    this.menuButtonItemEsriSupportCenter.Enabled = true;
                    this.menuButtonItemAbout.Enabled = true;
                }
                else if (sender == this._zoomMenu) {
                    foreach (ZoomMenuItem item in this._zoomMenu.Items) {
                        item.Checked = (activeModel != null && activeModel.Zoom == item.Zoom);
                    }
                }
            }
            catch (Exception ex) {
                ExceptionDialog.HandleException(ex);
            }
        }
Esempio n. 48
0
		private void sandDockManager1_ResolveDockControl(object sender, TD.SandDock.ResolveDockControlEventArgs e)
		{
			AppendLog("Resolve DockControl: " + e.Guid.ToString());
		}
Esempio n. 49
0
 private void menuFile_BeforePopup(object sender, TD.SandBar.MenuPopupEventArgs e)
 {
 }
Esempio n. 50
0
		private void sandDockManager1_DockControlActivated(object sender, TD.SandDock.DockControlEventArgs e)
		{
			AppendLog("Activated: " + e.DockControl.Text);

			lastActivatedWindow = e.DockControl;
		}
Esempio n. 51
0
 private void toolBarWikiServer_ButtonClick(object sender, TD.SandBar.ToolBarItemEventArgs e)
 {
     if(e.Item == buttonItemConnect)
     {
         ConnectToWiki();
     }
 }
            public bool CalculateKeys(T target, Message messageToReadHeaders, out InstanceKey instanceKey,
                                      out ICollection <InstanceKey> additionalKeys)
            {
                SelectRuntime select;

                instanceKey    = InstanceKey.InvalidKey;
                additionalKeys = null;

                // this is a query on the serverside, either Receive or SendReply
                // Where
                if (!this.ExecuteWhere(target, messageToReadHeaders, this.parent.whereRuntime, out select))
                {
                    return(false);
                }

                Dictionary <string, string> values = new Dictionary <string, string>();

                // Select
                if (select.Select.Count > 0)
                {
                    bool allOptional = true;

                    foreach (KeyValuePair <MessageQuery, string> result in this.ExecuteSelect(target, messageToReadHeaders, select.Select, select.IsContextQuery))
                    {
                        if (!(result.Key is OptionalMessageQuery))
                        {
                            allOptional = false;
                        }

                        if (!string.IsNullOrEmpty(result.Value))
                        {
                            values.Add(select.Select[result.Key], result.Value);
                        }
                    }

                    if (values.Count == 0)
                    {
                        if (!allOptional)
                        {
                            throw FxTrace.Exception.AsError(new ProtocolException(SR2.EmptyCorrelationQueryResults));
                        }
                    }
                    else
                    {
                        instanceKey = this.GetInstanceKey(values);
                        if (TD.TraceCorrelationKeysIsEnabled())
                        {
                            TraceCorrelationKeys(instanceKey, values);
                        }
                    }
                }

                // SelectAdditional
                foreach (KeyValuePair <string, MessageQueryTable <string> > item in select.SelectAdditional)
                {
                    if (additionalKeys == null)
                    {
                        additionalKeys = new List <InstanceKey>();
                    }

                    values.Clear();

                    InstanceKey additionalKey = InstanceKey.InvalidKey;
                    bool        allOptional   = true;

                    foreach (KeyValuePair <MessageQuery, string> result in this.ExecuteSelect(target, messageToReadHeaders, item.Value, select.IsContextQuery))
                    {
                        if (!(result.Key is OptionalMessageQuery))
                        {
                            allOptional = false;
                        }

                        if (!string.IsNullOrEmpty(result.Value))
                        {
                            values.Add(item.Value[result.Key], result.Value);
                        }
                    }

                    if (values.Count == 0)
                    {
                        if (!allOptional)
                        {
                            throw FxTrace.Exception.AsError(new ProtocolException(SR2.EmptyCorrelationQueryResults));
                        }
                    }
                    else
                    {
                        additionalKey = new CorrelationKey(values, this.parent.scopeName.ToString(), null)
                        {
                            Name = item.Key
                        };
                        if (TD.TraceCorrelationKeysIsEnabled())
                        {
                            TraceCorrelationKeys(additionalKey, values);
                        }
                    }

                    additionalKeys.Add(additionalKey);
                }

                return(true);
            }
Esempio n. 53
0
        private void ContextMenu_BeforePopup(object sender, TD.SandBar.MenuPopupEventArgs e) {
            try {
                // Exit if no Context Element
                if (this._elementContext == null) { return; }

                if (sender == this.contextDomainCodedValue) {
                    this.menuItemDomainCodedValue_OpenDiagram.Enabled = true;
                    this.menuItemDomainCodedValue_AddCodedValue.Enabled = true;
                    this.menuItemDomainCodedValue_Validate.Enabled = true;
                }
                else if (sender == this.contextDomainCodedValueItem) {
                    this.menuItemDomainCodedValueItem_Delete.Enabled = true;
                }
                else if (sender == this.contextDomainRange) {
                    this.menuItemDomainRange_OpenDiagram.Enabled = true;
                    this.menuItemDomainRange_Validate.Enabled = true;
                }
                else if (sender == this.contextFeatureClass) {
                    FeatureClass featureClass = (FeatureClass)this._elementContext;
                    this.menuItemFeatureClass_AddField.Enabled = true;
                    this.menuItemFeatureClass_AddIndex.Enabled = true;
                    this.menuItemFeatureClass_Validate.Enabled = true;
                    this.menuItemFeatureClass_ViewMetadata.Enabled = !string.IsNullOrEmpty(featureClass.Metadata);
                }
                else if (sender == this.contextFeatureDataset) {
                    FeatureDataset featureDataset = (FeatureDataset)this._elementContext;
                    this.menuItemFeatureDataset_Validate.Enabled = true;
                    this.menuItemFeatureDataset_ViewMetadata.Enabled = !string.IsNullOrEmpty(featureDataset.Metadata);
                }
                else if (sender == this.contextField) {
                    this.menuItemField_AddToIndexes.Enabled = true;
                    this.menuItemField_Delete.Enabled = true;
                }
                else if (sender == this.contextGeometricNetwork) {
                    GeometricNetwork geometricNetwork = (GeometricNetwork)this._elementContext;
                    this.menuItemGeometricNetwork_OpenDiagram.Enabled = true;
                    this.menuItemGeometricNetwork_OpenEdgeEdgeDiagram.Enabled = true;
                    this.menuItemGeometricNetwork_OpenEdgeJunctionDiagram.Enabled = true;
                    this.menuItemGeometricNetwork_ViewMetadata.Enabled = !string.IsNullOrEmpty(geometricNetwork.Metadata);
                }
                else if (sender == this.contextIndex) {
                    this.menuItemIndex_AddField.Enabled = true;
                    this.menuItemIndex_Delete.Enabled = true;
                }
                else if (sender == this.contextIndexField) {
                    this.menuItemIndexField_Delete.Enabled = true;
                }
                else if (sender == this.contextNetwork) {
                    // None
                }
                else if (sender == this.contextObjectClass) {
                    ObjectClass objectClass = (ObjectClass)this._elementContext;
                    this.menuItemObjectClass_AddField.Enabled = true;
                    this.menuItemObjectClass_AddIndex.Enabled = true;
                    this.menuItemObjectClass_Validate.Enabled = true;
                    this.menuItemObjectClass_ViewMetadata.Enabled = !string.IsNullOrEmpty(objectClass.Metadata);
                }
                else if (sender == this.contextRasterBand) {
                    RasterBand rasterBand = (RasterBand)this._elementContext;
                    this.menuItemRasterBand_AddField.Enabled = true;
                    this.menuItemRasterBand_AddIndex.Enabled = true;
                    this.menuItemRasterBand_Validate.Enabled = true;
                    this.menuItemRasterBand_ViewMetadata.Enabled = !string.IsNullOrEmpty(rasterBand.Metadata);
                }
                else if (sender == this.contextRasterCatalog) {
                    RasterCatalog rasterCatalog = (RasterCatalog)this._elementContext;
                    this.menuItemRasterCatalog_AddField.Enabled = true;
                    this.menuItemRasterCatalog_AddIndex.Enabled = true;
                    this.menuItemRasterCatalog_Validate.Enabled = true;
                    this.menuItemRasterCatalog_ViewMetadata.Enabled = !string.IsNullOrEmpty(rasterCatalog.Metadata);
                }
                else if (sender == this.contextRasterDataset) {
                    RasterDataset rasterDataset = (RasterDataset)this._elementContext;
                    this.menuItemRasterDataset_Validate.Enabled = true;
                    this.menuItemRasterDataset_ViewMetadata.Enabled = !string.IsNullOrEmpty(rasterDataset.Metadata);
                }
                else if (sender == this.contextRelationship) {
                    RelationshipClass relationshipClass = (RelationshipClass)this._elementContext;
                    this.menuItemRelationship_AddField.Enabled = true;
                    this.menuItemRelationship_AddIndex.Enabled = true;
                    this.menuItemRelationship_OpenDiagram.Enabled = true;
                    this.menuItemRelationship_Validate.Enabled = true;
                    this.menuItemRelationship_ViewMetadata.Enabled = !string.IsNullOrEmpty(relationshipClass.Metadata);
                }
                else if (sender == this.contextSubtype) {
                    Subtype subtype = (Subtype)this._elementContext;
                    this.menuItemSubtype_AddField.Enabled = true;
                    this.menuItemSubtype_SetAsDefault.Enabled = !subtype.Default;
                    this.menuItemSubtype_Validate.Enabled = true;
                }
                else if (sender == this.contextSubtypeField) {
                    this.menuItemSubtypeField_Delete.Enabled = true;
                }
                else if (sender == this.contextTerrain) {
                    Terrain terrain = (Terrain)this._elementContext;
                    this.menuItemTerrain_OpenDiagram.Enabled = true;
                }
                else if (sender == this.contextTopology) {
                    Topology topology = (Topology)this._elementContext;
                    this.menuItemTopology_OpenDiagram.Enabled = true;
                    this.menuItemTopology_OpenRuleDiagram.Enabled = true;
                    this.menuItemTopology_Validate.Enabled = true;
                    this.menuItemTopology_ViewMetadata.Enabled = !string.IsNullOrEmpty(topology.Metadata);
                }
            }
            catch (Exception ex) {
                ExceptionDialog.HandleException(ex);
            }
        }
Esempio n. 54
0
        // int frame = 0;

        void OnGUI()
        {
            // Debug.Log("OnGUI");
            ShowMessages();

            if (correctSetup == -1)
            {
                TC.AddMessage("Close and re-open the TerrainComposer window.");
                return;
            }

            if (correctSetup == -2)
            {
                TC.AddMessage("Can't load default project.\nThis file is needed -> TerrainComposer2/Defaults/TerrainComposer2.prefab.\n\n Please try to close and re-open the TerrainComposer window.");
                return;
            }

            if (correctSetup != 0)
            {
                return;
            }

            if (!TD.Init())
            {
                return;
            }

            settings = TC_Settings.instance;
            TC_Reporter.BenchmarkStart();

            TD.countDrawNode = TD.countDrawNodeCulled = 0;

            TD.hoverItem = null;

            TD.rectWindow = new Rect(0, 0, window.position.width, window.position.height);

            settings.selectionOld = Selection.activeTransform;

            if (terrainLayer == null)
            {
                GetLayerLevel();
            }

            Keys();
            ScrollInterface();

            TD.eventCurrent = eventCurrent;

            GUI.DrawTexture(new Rect(0, 0, window.position.width, window.position.height), TD.texShelfBackground1);

            settings.HasMasterTerrain();

            TD.showSelectRect = false;

            CaptureWindowEvents();

            TD.scrollMax = Vector2.zero;

            TC_TerrainLayerGUI.Draw(terrainLayer);
            DrawCommand.DrawCommandLists();

            TC_ItemBehaviourEditor.CheckKeyLockOnSelection(eventCurrent);

            TD.DrawCenter(Color.red, 21, 1);
            TD.DrawCenter(Color.red, 11, 3);

            DrawMenu();

            DropDownMenuMain();

            if (settings.showFps)
            {
                if (!EditorGUIUtility.isProSkin)
                {
                    GUI.color = new Color(1, 1, 1, 0.5f);
                    GUI.DrawTexture(new Rect(180, 0, 250, 17), Texture2D.whiteTexture);
                    GUI.color = Color.white;
                }
                string fps = TC_Reporter.BenchmarkStop("| fps ", false);
                EditorGUI.LabelField(new Rect((TC_NodeWindow.window.position.width / 2) - 200, 0, 250, 17), "Node Draw " + TD.countDrawNode + "| Nodes Culled " + TD.countDrawNodeCulled + fps);
            }

            //if (onFocus && correctSetup == 0 && ++frame == 20)
            //{
            //    frame = 0;
            //    Repaint();
            //}
        }