1 страниц (16 вхождений)
Contributing plugins - Сообщения
#1 Опубликовано: 10.01.2012 21:43:21
Andrey,
How do you want to handle plugins? I have two that I will migrate to 0.9 this weekend. One has the MathCad equivalent financial functions and the other a way to store and pass data between SMath files.
How do you want to handle plugins? I have two that I will migrate to 0.9 this weekend. One has the MathCad equivalent financial functions and the other a way to store and pass data between SMath files.
Ed
#2 Опубликовано: 11.01.2012 05:57:53
Hello Ed.
The best way to handle plugins is to create some plugins register here on the site. I plan to do it in future.
But for now... Is it possible for you to upload the sources you've created to project's shared (visible for all under the green Code button on the top of the forum's pages) or to my closed (you and me will be the only people who will have access to it; I can remove the code after reviewing and compiling it if you want) SVN repository. It is preferred for me because I need to check any sources for the danger code and compile it myself before introducing resulting binaries to the community. Hope you'll understand me well. I think this will provide the best protection of users computers and data while plugins register is not created yet.
Please check How to create plugins for SMath Studio topic regarding shared repository details (to have write permissions request for the login/pass via PM or e-mail to me). If you need any help about SVN, please just inform me.
P.S.: If you will agree to share sources with me, I will update them in case of interfaces (api) changed after every next release.
Thank you for your offer! It's a pleasure.
Best regards, Andrey Ivashov.
The best way to handle plugins is to create some plugins register here on the site. I plan to do it in future.
But for now... Is it possible for you to upload the sources you've created to project's shared (visible for all under the green Code button on the top of the forum's pages) or to my closed (you and me will be the only people who will have access to it; I can remove the code after reviewing and compiling it if you want) SVN repository. It is preferred for me because I need to check any sources for the danger code and compile it myself before introducing resulting binaries to the community. Hope you'll understand me well. I think this will provide the best protection of users computers and data while plugins register is not created yet.
Please check How to create plugins for SMath Studio topic regarding shared repository details (to have write permissions request for the login/pass via PM or e-mail to me). If you need any help about SVN, please just inform me.
P.S.: If you will agree to share sources with me, I will update them in case of interfaces (api) changed after every next release.
Thank you for your offer! It's a pleasure.
Best regards, Andrey Ivashov.
#3 Опубликовано: 12.01.2012 23:00:41
Do we still compile for .NET Framework 2.0?
Ed
#4 Опубликовано: 13.01.2012 00:01:37
- The most preferable is .Net Compact Framework 2.0 if you want to create a plugin for both Desktop and Handheld versions of SMath Studio (I can help you with it).
- To meet SMath Studio Desktop system requirement only you need to use .Net Framework 2.0 (plugin will work only on the desktops).
- You can use any .Net version you want, but you need to inform users about requirements they should follow. Though this is not recommended.
Regards.
#5 Опубликовано: 14.01.2012 00:54:31
Andrey,
A couple of questions.
First I'm not able to upload source code for the financial functions using TortoiseSVN. I may need some access permissions?
Second, I took the CheckBox plugin and converted to Visual Basic. I can insert a checkbox to the SMath desktop but when I click on it SMath shuts down. Could you take a look at my source code and see where I made my mistake? One thing I noticed is where does args come from in InsertCheckbox? Thanks.
Code removed by TheWizEd see following post
A couple of questions.
First I'm not able to upload source code for the financial functions using TortoiseSVN. I may need some access permissions?
Second, I took the CheckBox plugin and converted to Visual Basic. I can insert a checkbox to the SMath desktop but when I click on it SMath shuts down. Could you take a look at my source code and see where I made my mistake? One thing I noticed is where does args come from in InsertCheckbox? Thanks.
Code removed by TheWizEd see following post
Ed
#6 Опубликовано: 14.01.2012 03:34:44
WroteFirst I'm not able to upload source code for the financial functions using TortoiseSVN. I may need some access permissions?
I've sent your login and password to SVN via private messages.
WroteCould you take a look at my source code and see where I made my mistake?
I don't see the following line in your code (it should be inside the OnCommandSend method:
RequestForEvaluation(CalculateType.Numeric, this, false);
Regards.
#7 Опубликовано: 14.01.2012 05:15:57
Okay, I uploaded the code to plugins. I'll look in to my omission after the NFL playoff games today. Thanks for your help.
Ed
#8 Опубликовано: 15.01.2012 02:26:12
Opps, I meant to go back to that but forgot. I've included the request for evaluation and can place a checkbox but as soon as I click on the desktop SMath shuts down.
Code removed by TheWizED see following post.
What I'm not clear on does InsertCheckBox have to implement anything and where does the args parameter come from?
Code removed by TheWizED see following post.
What I'm not clear on does InsertCheckBox have to implement anything and where does the args parameter come from?
Ed
#9 Опубликовано: 15.01.2012 05:18:37
Okay I finally got it to work.
In the AddDefinition the last argument should be Nothing unless the definition is a function.
In the AddDefinition the last argument should be Nothing unless the definition is a function.
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports SMath.Manager
Imports SMath.Control
Public Class Implementer : Implements IPluginCustomRegion
Dim assemblyInfos() As AssemblyInfo
Dim menuButtons() As MenuButton
Dim dragDropFileTypes() As DragAndDropFileType
Public Function CreateNew() As SMath.Control.RegionBase Implements SMath.Control.IPluginCustomRegion.CreateNew
Return New CheckBox()
End Function
Public ReadOnly Property DragAndDropFileTypes As SMath.Control.DragAndDropFileType() Implements SMath.Control.IPluginCustomRegion.DragAndDropFileTypes
Get
' No Drag'n'Drop files supported
Return Me.dragDropFileTypes
End Get
End Property
Public Function GetContextMenuItems(region As SMath.Control.RegionBase) As SMath.Control.MenuButton() Implements SMath.Control.IPluginCustomRegion.GetContextMenuItems
Return New MenuButton() {New MenuButton("xxx"
}
End Function
Public ReadOnly Property IsCurrentClipboardSupported As Boolean Implements SMath.Control.IPluginCustomRegion.IsCurrentClipboardSupported
Get
' No external clipboard data supported
Return False
End Get
End Property
Public ReadOnly Property MenuItems As SMath.Control.MenuButton() Implements SMath.Control.IPluginCustomRegion.MenuItems
Get
Return Me.menuButtons
End Get
End Property
Public ReadOnly Property Dependences As SMath.Manager.AssemblyInfo() Implements SMath.Manager.IPlugin.Dependences
Get
Return Me.assemblyInfos
End Get
End Property
Public Sub InsertCheckbox(args As MenuButtonArgs)
args.CurrentRegion = New CheckBox()
End Sub
Public Sub Initialize() Implements SMath.Manager.IPlugin.Initialize
Me.assemblyInfos = New AssemblyInfo() {New AssemblyInfo("SMath Studio", New Version(0, 90), New Guid("a37cba83-b69c-4c71-9992-55ff666763bd"
)}
Me.dragDropFileTypes = New DragAndDropFileType() {New DragAndDropFileType(Nothing, Nothing)}
Me.menuButtons = New MenuButton() {New MenuButton("CheckBox", AddressOf Me.InsertCheckbox)}
End Sub
#Region "IDisposable Support"
Private disposedValue As Boolean ' To detect redundant calls
' IDisposable
Protected Overridable Sub Dispose(disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
' TODO: dispose managed state (managed objects).
End If
' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below.
' TODO: set large fields to null.
End If
Me.disposedValue = True
End Sub
' TODO: override Finalize() only if Dispose(ByVal disposing As Boolean) above has code to free unmanaged resources.
'Protected Overrides Sub Finalize()
' ' Do not change this code. Put cleanup code in Dispose(ByVal disposing As Boolean) above.
' Dispose(False)
' MyBase.Finalize()
'End Sub
' This code added by Visual Basic to correctly implement the disposable pattern.
Public Sub Dispose() Implements IDisposable.Dispose
' Do not change this code. Put cleanup code in Dispose(ByVal disposing As Boolean) above.
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
#End Region
End Class
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Xml
Imports SMath.Manager
Imports SMath.Control
Public Class CheckBox : Inherits SMath.Control.RegionEvaluable
Dim bChecked As Boolean
Public Sub New()
MyBase.New()
Me.bChecked = False
MyBase.Terms = New Term() {New Term("checked", TermType.Operand, 0)}
MyBase.Size = New Size(22, 22)
End Sub
Public Sub New(region As CheckBox)
MyBase.New(region)
Me.bChecked = region.Checked
End Sub
Public Overrides Sub Evaluate(store As SMath.Math.Store)
If (MyBase.Terms.Length = 1) And (MyBase.Terms(0).Type = TermType.Operand) Then
If bChecked Then
store.AddDefinition(MyBase.Terms(0).Text, New Term() {New Term("1", TermType.Operand, 0)}, Nothing)
Else
store.AddDefinition(MyBase.Terms(0).Text, New Term() {New Term("0", TermType.Operand, 0)}, Nothing)
End If
End If
End Sub
Public Overrides Function Clone() As SMath.Control.RegionBase
Return New CheckBox(Me)
End Function
Public Overrides Sub FromXml(reader As System.Xml.XmlTextReader, parsingContext As SMath.Control.FileParsingContext)
Me.bChecked = Convert.ToBoolean(reader.GetAttribute("checked"
)
End Sub
Public Overrides Sub ToXml(writer As System.Xml.XmlTextWriter, parsingContext As SMath.Control.FileParsingContext)
writer.WriteAttributeString("checked", Me.bChecked.ToString.ToLower)
End Sub
Public Overrides Sub OnCommandSend(s As String)
If s = " " Then
Me.Focused = True
Me.InDate = False
bChecked = Not bChecked
' Request evaluation as soon as value changes
RequestForEvaluation(CalculateType.Numeric, Me, False)
End If
MyBase.OnCommandSend(s)
End Sub
Public Overrides Sub OnPaint(e As PaintEventArgs)
MyBase.OnPaint(e)
If bChecked Then
e.Graphics.FillRectangle(Brushes.Black, e.ClipRectangle.X + 1, e.ClipRectangle.Y + 1, e.ClipRectangle.Width - 2, e.ClipRectangle.Height - 2)
Else
e.Graphics.FillRectangle(Brushes.LightGray, e.ClipRectangle.X + 1, e.ClipRectangle.Y + 1, e.ClipRectangle.Width - 2, e.ClipRectangle.Height - 2)
End If
End Sub
Public Overrides Sub OnMouseDown(e As MouseEventArgs)
MyBase.OnMouseDown(e)
OnCommandSend(" "
End Sub
Public Property Checked()
Get
Return bChecked
End Get
Set(value)
bChecked = value
End Set
End Property
End Class
Ed
#10 Опубликовано: 21.01.2012 10:03:46
Toying with controls, I changed the name of the class from CheckBox to SMCheckBox. I can insert a new SMCheckBox and toggle it. It gets saved to the sm file but won't read back in. What might I be doing wrong?
Ed
#11 Опубликовано: 21.01.2012 11:33:20
Ed, did you try to debug?
Regards, Andrey Ivashov.
Regards, Andrey Ivashov.
#12 Опубликовано: 21.01.2012 13:47:19
Sort of. Until today I've been using Msgbox to communicate but today I switched to Debug. Much better. What I found is FromXML never gets called nor does CreateNew. I believe these two are used to create a check box from the sm file.
<region id="0" left="126" top="108" width="22" height="22" border="true" color="#000000" background-color="#ffffff">
<smcheckbox name="cbCheckBox1" checked="false">
<input>
<e type="operand">cbCheckBox1</e>
</input>
</smcheckbox>
</region>
Public Overrides Sub FromXml(reader As System.Xml.XmlTextReader, parsingContext As SMath.Control.FileParsingContext)
Me.sName = Convert.ToString(reader.GetAttribute("name"
)
Me.bChecked = Convert.ToBoolean(reader.GetAttribute("checked"
)
MsgBox("FromXml"
End Sub
Public Overrides Sub ToXml(writer As System.Xml.XmlTextWriter, parsingContext As SMath.Control.FileParsingContext)
writer.WriteAttributeString("name", Me.sName)
writer.WriteAttributeString("checked", Me.bChecked.ToString.ToLower)
MsgBox("ToXml"
End Sub
Ed
#13 Опубликовано: 21.01.2012 15:04:03
Ok. Fact is that tag of the region in result XML (.sm file) composing according to plugin DLL name. F.e. PlotRegion.dll will create tag " ", CheckBoxRegion.dll - " ". I recommend you also to name the class same as you've named a DLL file.
#14 Опубликовано: 21.01.2012 17:32:27
I was thinking of creating several controls, Button, CheckBox, ComboBox. The menu item is Controls with Button, CheckBox, ComboBox as sub MenuItems. I know the ComboBox will be difficult to paint now that I understand the process better. But what are weekends for. The ContextMenuItem would bring up a dialog so the user could edit the properties of the control. So Implementer would control all Controls.
Looks like not possible at this time. I'll continue to work on each seperately.
Thanks for the advise.
Looks like not possible at this time. I'll continue to work on each seperately.
Thanks for the advise.
Ed
#15 Опубликовано: 23.01.2012 15:33:52
In fact I've been able to come up with a solution to have multiple controls in one DLL. I created a class called ControlsRegion. Within the class there can be several control types. Each class method uses a switch to determine for each type what to do. I've got it working for a button and a checkbox. I'm working on the context menu item to edit the properties of the control from the SMath desktop. Next will be combobox and option button.
The controls I've developed so far have a unique name and a caption. The controls get saved to the sm file and read back in okay.
The controls I've developed so far have a unique name and a caption. The controls get saved to the sm file and read back in okay.
Ed
1 пользователям понравился этот пост
Andrey Ivashov 23.01.2012 19:55:00
#16 Опубликовано: 27.08.2012 21:38:53
Hi,
I tried to create a small plugin, which returns the maximum and minimum values from a list of values...
I need a little help... how I can handle the items of MDA?
edit: solved with Symbolic plugin
regards,
w3b5urf3r
attachments updated: Max() and Min() arguments now can be also vector, matrices an systems (not nested)
customFunctions.dll.zip (3 КиБ) скачан 55 раз(а).
I tried to create a small plugin, which returns the maximum and minimum values from a list of values...
I need a little help... how I can handle the items of MDA?
public Term[] getMax(Term[] val1, Term[] val2, Store store)
{
List<Term> gmResult = new List<Term>();
gmResult.AddRange(val1);
if (val1[val1.Length-1].ToString().StartsWith("mat("
)
{
gmResult.Add(new Term(Functions.Max, TermType.Function, 1));
if (val2 != null)
{
gmResult.AddRange(val2);
gmResult.Add(new Term(Operators.BooleanMoreOrEqual, TermType.Operator, 2));
gmResult.AddRange(val1);
gmResult.Add(new Term(Functions.Max, TermType.Function, 1));
gmResult.AddRange(val2);
gmResult.Add(new Term(Functions.If, TermType.Function, 3));
}
}
else
{
if (val2 != null)
{
gmResult.AddRange(val2);
gmResult.Add(new Term(Operators.BooleanMoreOrEqual, TermType.Operator, 2));
gmResult.AddRange(val1);
gmResult.AddRange(val2);
gmResult.Add(new Term(Functions.If, TermType.Function, 3));
}
}
return Decision.Preprocessing(gmResult.ToArray(), ref store);
}
edit: solved with Symbolic plugin

regards,
w3b5urf3r
attachments updated: Max() and Min() arguments now can be also vector, matrices an systems (not nested)
customFunctions.dll.zip (3 КиБ) скачан 55 раз(а).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
2 пользователям понравился этот пост
1 страниц (16 вхождений)
-
Новые сообщения
-
Нет новых сообщений