I'm making an autocad plugin and i want to create a new entity that is a combination of a line and the text.If i select the line the text is selected and backwords when i delete the line delete the text etc etc.How to treat them as one object referencing eachother?Is this possible?
I recommend using groups. Below is a link on how to access groups, I'm sure that site has more information on creating groups.
Users can control whether objects are selected with the group based on the system variable, PICKSTYLE. you can use ctrl+ h to toggle the PICKSTYLE value.
http://adndevblog.typepad.com/autocad/2012/04/how-to-detect-whether-entity-is-belong-to-any-group-or-not.html
Another option - though it doesn't answer your question - and this is something for you to think about: is to create a new block which consists of the line and some text. The line can be an entity in your block, and the text can be a tag string value. the tag can be called "line_information".
I know this might be abit too late but there is a better more flexible way to do this, although it's not actually combining the two entities but rather more of a visual effect.
It's called using Overrules. Basically you change the way the entity is displayed. So instead of displaying a line, you can display a circle, or in your case display a text and a line.
Overruling is a very powerful tool, you can not only change how the entity looks but also add grips, remove grips, change how entity is highlighted or highlight other entities when your entity is highlighted, override some of the entity methods like erase and much more.
Best place to start from is Kean Walmsley's "Through the Interface" blog.
And here is a link to this blog related to what you want to achieve
http://through-the-interface.typepad.com/through_the_interface/2009/08/a-simple-overrule-to-change-the-way-autocad-lines-are-displayed-using-net.html
Related
Hi :) What I'm trying to achieve is creating a Contact selector that, when you click on the selector icon, it brings up a filtered result of the contacts table that only shows Contacts related to that specific company, as shown below:
The above image is in the Sales Orders screen, and I'm aiming to actually have it in the Projects screen. So when I tried moving it over, making sure to have the same setup, it doesn't seem to be working in the Projects screen.
When I try opening the selector, the box is empty. I thought that maybe the problem was that the values I was trying to match between the PMProject table and the BAccount table weren't matching, so I used the Description field to output the values I was getting, and they appear to be the same.
This is the setup I am using to create the selector:
[PXUIField(DisplayName="Contact")]
[PXSelector(typeof(Search2<Contact.displayName,
LeftJoin<BAccount, On<BAccount.bAccountID, Equal<Contact.bAccountID>>>,
Where<Contact.contactType, Equal<ContactTypesAttribute.person>>>))]
[PXRestrictor(typeof(
Where<Current<PMContact.customerID>,
Like<BAccount.bAccountID>>), "")]
It's exactly the same setup that I was using for the Sales Order screen, just obviously now it's using the CustomerID of PMProject instead.
Is there something I am doing incorrectly? Any help would be appreciated :D
UPDATE
Thanks for the answer Joseph! The contact field still shows up as being empty when I click into it. See below:
This is how I added the solution:
It seems that your join with the BAccount might not be required.
Also, where are you using the displayname in "Search2<Contact.displayName"?
Did you try something like this:
[PXSelector(typeof(Search<Contact.contactID, Where<Contact.contactType, Equal<ContactTypesAttribute.person>,
And<Where<Contact.contactID, Equal<Current<PMContact.customerID>>>>>>))]
I managed to solve this issue. Joseph's answer made me rethink how I was matching contacts with the current project, as instead of using the BAccount table, I could use the Contact table instead.
I found that I just needed to compare the Contact.bAccountID field with the value of the PMContact.customerID field, and that would give me all the associated contacts.
Adding this comparison to the PXRestrictor solved this issue for me :)
[PXDBString(50)]
[PXUIField(DisplayName="Contact")]
[PXSelector(typeof(Search2<Contact.displayName,
LeftJoin<BAccount, On<BAccount.bAccountID, Equal<Contact.bAccountID>>>,
Where<Contact.contactType, Equal<ContactTypesAttribute.person>>>))]
[PXRestrictor(typeof(
Where<Current<PMContact.customerID>,
Like<Contact.bAccountID>>), "")]
We have a large site and there are a few instances where a single basic content item is shared and re-used on 5 to 12 pages. The site has over 10 editors and at least half of those are infrequent, so not remembering that these items are shared is a repeated problem. They keep changing the content on one page adding specifics that then look weird, broken, or very out of place on one or more other pages.
What I would like to do is add some code to the View that detects the item is shared and then add an indicator. Obviously this would be perfect:
if(Content.IsSharedItem) {
// add a nice blue, round 2sxc style button with a
<i class="fas fa-share-alt"></i>
}
I poked around the API, but beyond writing some LINQ (that could be processor intensive), I haven't spotted any way to implement anything like .IsSharedItem
Any ideas or suggestions? Is there something built-in that I might not be aware of or named in a way that I didn't think to search? Any help would be greatly appreciated. Thank you in advance.
DNN 9.03.02, 2sxc 10.9.1, Content App 3.03
There actually is :).
Let's assume that shared means "it's been manually assigned to a module". In this case there is another Entity which references the one you are interested in.
Basically if you ask any item for .Parents("2SexyContent-ContentGroup") you should get all Content-Groups referencing it.
Just remember that some may be deleted etc. so it's not 100% reliable or would need more work.
I couldn't see how to get from .Parents() to TabID, so I realized, we are executing in the module, so simply doing Dnn.Module.ModuleSettings["ToSIC_SexyContent_ContentGroupGuid"] gives you what you need. Then DNN has no API way to reverse a ModuleSetting.SettingValue, e.g. there is no GetModulesByModuleSettingValue() type thing. So SQL started to make sense and I did this instead...
I would be really interested if anyone has ways to improve this. Better query? A way to do it without SQL? Refactor or simplify some things? For example, adding the TabName was an afterthought and probably should have been done in SQL.
Add this to any Content item View, wrap it in an if(Edit.Enabled) or something so only editors/admins see it.
#if(Edit.Enabled) {
#RenderPage("_Shared__ContentGroup-Info.cshtml")
}
Save this to a filename _Shared__ContentGroup-Tabs.cshtml (above)
#using System.Data
#using DotNetNuke.Data
#using DotNetNuke.Entities.Tabs
#*
This sub template is intended to
a) reveal whether or not the Content item is shared and
b) show links to those pages
Reminder the .Parents("2SexyContent-ContentGroup")..EntityGuid is what is stored in
Dnn.Module.ModuleSettings["ToSIC_SexyContent_ContentGroupGuid"]
*#
#{
string sql = #"
SELECT DISTINCT TabID
FROM TabModules
INNER JOIN ModuleSettings ON TabModules.ModuleID = ModuleSettings.ModuleID
WHERE ModuleSettings.SettingValue = '{0}'";
sql = string.Format(sql, Dnn.Module.ModuleSettings["ToSIC_SexyContent_ContentGroupGuid"]);
IList<int> tabs;
using (IDataContext db = DataContext.Instance()) {
tabs = db.ExecuteQuery<int>(CommandType.Text, sql).ToList();
}
}
<pre>
This Content item is shared to #(tabs.Count - 1) other page(s)
#foreach(int tabId in tabs
.Where(t => t != Dnn.Tab.TabID)
) {
#TabController.Instance.GetTab(tabId, Dnn.Portal.PortalId).TabName
}
</pre>
Example output:
So then, since we already have Bootstrap 4 and Fancybox on the pages, I was able to turn the experiment in to a working UI with about 5 more mins of playing around:
It's a struggle with any application that provides select fields, that are populated by a certain datasource: Everything works fine in the first place, but once the application ages, some older entries might be deleted, leading to the problem that prior select fields can no longer access the entity in question.
Opening a view, where a select points to an already deleted datarow will (best case) show empty string.
We designed our system in a way, that deletions are not real delete-operations, but only the setting of a deleted flag. (So, all the information is still there)
However, when using Databindings along with C# (or even if not) the most blatant use case is still not covered by general mechanics (I assume):
Select-Field should show all NOT-Deleted-Entities while creating a new object containing references to the entity in question.
Select-Field (populated the very same way) should show the "deleted" entity, if it was selected "days/months/years" ago.
Is there a "handy" solution to this?
Currently we are using a "Proxy-Method" for every datasource, which will reload the data of the deleted entity, if it's not in the "available data" collection - but it's hard to believe there is no better way to deal with this, as this problem applies for almost every language out there?
In a normalized database you would have a constraint with ON DELETE NO ACTION/RESTRICT event that would prevent removal of a referenced element from the list. It would force you to decide what is to be done with the referencing rows.
With your manually-controlled deletions this could have been covered by a trigger. As none of these were implemented, you are left with only one thing to do: updating the dropdown with the selected option before rendering the UI. My approach (in Java, I'm not good at C#):
List<String> options = getNonDeletedWhatever();
if (!options.contains(currentEntity.getWhatever())) {
options.add(currentEntity.getWhatever()); // This optionally inserts an outdated value
}
or simply:
Set<String> options = getNonDeletedWhatever();
options.add(currentEntity.getWhatever()); // This optionally inserts an outdated value
I solve it by creating a list of available (non-deleted) items and if the selected item is a deleted one, then I add that item to the list.
This list becomes the data source for my dropdown.
I am trying to delete a measure group A from the cube in C# using
//measureGroup is of type AS.MeasureGroup
measureGroup.Drop();
Since this measure group A exists in a many to many relationship in another measure group, how can I delete this relationship in c#. I want to drop this measure group and not drop the other measure groups as well.
Is there anything that I need to do before I drop the Measure Group?
Have you already tried it? In my opinion it should only affect the Dimensions which are using this many-to-many relationship. I.e. if you drop the intermediate MeasureGroup, you will not be able to get Results from the Many-To-Many dimension. If there are other dimensions using the target Measuregroup they should still be working. If you remove the target MeasureGroup and there are other dimensions related to the intermediate MeasureGroup, they too should still be functional.
But I must admit that I'm not really an expert when it comes to Analysis Services.
Maybe you post a short example of what you're trying to do?
I've created the bulk of a C# application, of which the core is a person database (there's a lot more going on peripherally too). I'm using EF with the CodeFirst/DbContext methodology. For my frontend, I have XAML using a MVVM type approach.
I would now like a search box which "feels" like a free-text search. I currently have an editable combo box, with properties set up to provide the correct feel. I am using EF's "Contains" query method to query the SQL database.
At present, I have something along the following lines:
x.Contains(p=> p.Forenames.Contains(s) || p.Surname.Contains(s))
Which works well to a limited extent. This is obviously a problem if "s", the search string, contains both first name and surname data. In essence, I want the user to be able to search by typing "Joe Bloggs" or "Bloggs, Joe" or various combinations of middle names etc... I may even want to add address data to the search in future.
My question is how I achieve this? The first way that springs to mind is to Split the string and then pass the individual components of the array to each search term, in a foreach loop. This could potentially result in multiple, rather large queries.
Is the a better way to achieve what I want to achieve through using a different query strategy with EF itself? I want to give the user the feeling that any search term they type provides something sensible in the combo box!