Skip to content

Commit

Permalink
Remove dependency on CodeProtect #200
Browse files Browse the repository at this point in the history
- there are still two places
  • Loading branch information
mpostol committed Feb 3, 2021
1 parent aa1f0ef commit cfd67d5
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 393 deletions.
36 changes: 17 additions & 19 deletions ModelDesigner.DesignStudio/Controls/FileMenuProviderControl.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//___________________________________________________________________________________
//
// Copyright (C) 2019, Mariusz Postol LODZ POLAND.
// Copyright (C) 2021, Mariusz Postol LODZ POLAND.
//
// To be in touch join the community at GITTER: https://gitter.im/mpostol/OPC-UA-OOI
//___________________________________________________________________________________

using CAS.UA.Model.Designer.Properties;
using CAS.UA.Model.Designer.Wrappers;
using System;
using System.Drawing;
Expand All @@ -15,7 +15,10 @@ namespace CAS.UA.Model.Designer.Controls
internal abstract class FileMenuProviderControl<TModel> : BaseTreeNodeControl<TModel>
where TModel : IBaseModel
{
public FileMenuProviderControl(TModel model) : base(model) { }
public FileMenuProviderControl(TModel model) : base(model)
{
}

/// <summary>
/// Adds the items to menu.
/// </summary>
Expand Down Expand Up @@ -49,50 +52,45 @@ internal virtual void AddItemsToMenu(ContextMenuStrip contextMenuStrip)
_Save.Size = new Size(175, 22);
_Save.Text = "&Save";
_Save.ToolTipText = "Save configuration to an XML file.";
if (SaveConstrain.IsLicensed)
_Save.Click += OnSave_Click;
else
{
_Save.ToolTipText = $"{_Save.ToolTipText} - {Resources.LicenseFeatureUnavailable}";
_Save.Enabled = false;
}
_Save.Click += OnSave_Click;
// _SaveAs
_SaveAs.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
_SaveAs.Name = "Configuration Save As";
_SaveAs.ShortcutKeys = Keys.Control | Keys.A;
_SaveAs.Size = new System.Drawing.Size(175, 22);
_SaveAs.Text = "Save &As...";
_SaveAs.ToolTipText = "Open a prompt file name dialog and save the configuration to an XML in a specified location and specified file name.";
if (SaveConstrain.IsLicensed)
_SaveAs.Click += OnSaveAs_Click;
else
{
_SaveAs.ToolTipText = $"{_SaveAs.ToolTipText} - {Resources.LicenseFeatureUnavailable}";
_SaveAs.Enabled = false;
}
_SaveAs.Click += OnSaveAs_Click;
ToolStripItem[] m_MenuItems = new ToolStripItem[] { _New, _Open, _Save, _SaveAs };
contextMenuStrip.Items.AddRange(m_MenuItems);
}

protected abstract void Open();

protected abstract void New();

protected abstract void Save();

protected abstract void SaveAs();

private void OnSaveAs_Click(object sender, EventArgs e)
{
SaveAs();
}

private void OnSave_Click(object sender, EventArgs e)
{
Save();
}

private void OnOpen_Click(object sender, EventArgs e)
{
Open();
}

private void OnNew_Click(object sender, EventArgs e)
{
New();
}

}
}
}
Original file line number Diff line number Diff line change
@@ -1,49 +1,44 @@
//___________________________________________________________________________________
//
// Copyright (C) 2019, Mariusz Postol LODZ POLAND.
// Copyright (C) 2021, Mariusz Postol LODZ POLAND.
//
// To be in touch join the community at GITTER: https://gitter.im/mpostol/OPC-UA-OOI
//___________________________________________________________________________________


using CAS.UA.Model.Designer.IO;
using CAS.UA.Model.Designer.Properties;
using CAS.UA.Model.Designer.Wrappers;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace CAS.UA.Model.Designer.Controls.NodeObserver
{
internal partial class BrowseViewObserver : SelectedItemObserver
{
#region creator

public BrowseViewObserver()
: base()
{
InitializeComponent();
if (LicenseManager.CurrentContext.UsageMode == LicenseUsageMode.Designtime)
return;
CheckLicense();
this.m_BrowseViewTreeView.AfterSelect += new BrowseViewTreeView.BrowseViewTreeViewEventHandler(this.BrowseViewTreeView_AfterSelect);
}
#endregion

#endregion creator

#region private
[LicenseProvider(typeof(CAS.Lib.CodeProtect.CodeProtectLP))]
[GuidAttribute("D3028D63-52A1-4a66-9946-B8048C459AC7")]
private sealed class LicenseProtection : StartUpSplashScreen.LogedIsLicensed<LicenseProtection> { }

private bool mBuildIsRequired = true;
private void CheckLicense()

private void SetPleaseWaitTextStep1()
{
if (new LicenseProtection().Licensed)
{
this.m_BrowseViewTreeView.AfterSelect += new BrowseViewTreeView.BrowseViewTreeViewEventHandler(this.BrowseViewTreeView_AfterSelect);
}
else
this.RemoveMeFromParentTabControl();
m_LabelPleaseWait.Text = Resources.BrowseViewObserver_pleasewait_step1;
}
private void SetPleaseWaitTextStep1() { m_LabelPleaseWait.Text = Resources.BrowseViewObserver_pleasewait_step1; }

private void HideWaitMessage()
{
m_ProgressBarPleaseWait.Value = m_ProgressBarPleaseWait.Maximum;
Expand All @@ -52,25 +47,30 @@ private void HideWaitMessage()
}

#region handlers

private void TimerPleaseWait_Tick(object sender, EventArgs e)
{
m_ProgressBarPleaseWait.PerformStep();
if (m_ProgressBarPleaseWait.Value >= m_ProgressBarPleaseWait.Maximum)
m_ProgressBarPleaseWait.Value = m_ProgressBarPleaseWait.Minimum;
}

private void BrowseViewTreeView_AfterSelect(object sender, BrowseViewTreeView.BrowseViewTreeViewEventArgs e)
{
GenerateSelectedItemIsChangeEvent(e.ModelNode);
}

private void GenerateSelectedItemIsChangeEvent(IModelNode node)
{
SelectedItemEventArgs args = new SelectedItemEventArgs(node, false);
RaiseSelectedItemIsChanged(args);
}

private void BrowseViewTreeView_VisibleChanged(object sender, EventArgs e)
{
TestIfBuildIsRequiredAndDoTheBuild(false);
}

private void TestIfBuildIsRequiredAndDoTheBuild(bool SolutionHasBeenChanged)
{
if (this.BackgroundWorkerAddressspaceIniialiser == null)
Expand Down Expand Up @@ -99,12 +99,14 @@ private void TestIfBuildIsRequiredAndDoTheBuild(bool SolutionHasBeenChanged)
}
}
}

private void BackgroundWorkerAddressspaceIniialiser_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
IElement[] _asInstance = AddressSpaceService.CreateInstance(SolutionTreeNode.SolutionRoot.ResetAndAddToAddressSpace, x => worker.ReportProgress(1, x));
e.Result = _asInstance;
}

private void BackgroundWorkerAddressspaceIniialiser_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
this.HideWaitMessage();
Expand All @@ -120,31 +122,36 @@ private void BackgroundWorkerAddressspaceIniialiser_RunWorkerCompleted(object se
return;
m_BrowseViewTreeView.Show((IElement[])e.Result, true);
}

private void BackgroundWorkerAddressspaceIniialiser_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Information, 132, (String)e.UserState);
}

#endregion handlers

#endregion SelectedItemObserver
#endregion private

#region protected

protected override void AfterSolutionChange(object sender, SolutionConfigurationManagementRoot.AfterSolutionChangeEventArgs e)
{
mBuildIsRequired = true;
TestIfBuildIsRequiredAndDoTheBuild(true);
}

protected override void AfterSolution_OnDataChanged(object sender, EventArgs e)
{
base.AfterSolution_OnDataChanged(sender, e);
mBuildIsRequired = true;
}

protected override void OnSelectedItemIsChanged(object sender, SelectedItemEventArgs e)
{
if (e.IsOnlyModification)
mBuildIsRequired = true;
}
#endregion

#endregion protected
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
//<summary>
// Title : View 3D of Model - Selected item Observer
// System : Microsoft Visual C# .NET 2008
// $LastChangedDate$
// $Rev$
// $LastChangedBy$
// $URL$
// $Id$
//___________________________________________________________________________________
//
// Copyright (C)2009, CAS LODZ POLAND.
// TEL: +48 (42) 686 25 47
// mailto://[email protected]
// http://www.cas.eu
//</summary>
// Copyright (C) 2021, Mariusz Postol LODZ POLAND.
//
// To be in touch join the community at GITTER: https://gitter.im/mpostol/OPC-UA-OOI
//___________________________________________________________________________________

using CAS.UA.Model.Designer.IO;
using CAS.UA.Model.Designer.Wrappers;
Expand Down Expand Up @@ -230,25 +222,15 @@ public View3DModelObserver()
InitializeComponent();
if (LicenseManager.CurrentContext.UsageMode == LicenseUsageMode.Designtime)
return;
if (new LicenseProtection().Licensed)
{
this.VisibleChanged += new EventHandler(View3DModelObserver_VisibleChanged);
this.panel3DUserControl1.CommandPanelBackgroundBrush = new LinearGradientBrush(new GradientStopCollection
(new GradientStop[] { new GradientStop(Colors.Green, 0), new GradientStop(Colors.White, 0.5), new GradientStop(Colors.Green, 1) }));
this.panel3DUserControl1.MeshDiagramViewport3D.IModelVisualIsSelected += new EventHandler(MeshDiagramViewport3D_IModelVisualIsSelected);
}
else
this.RemoveMeFromParentTabControl();
this.VisibleChanged += new EventHandler(View3DModelObserver_VisibleChanged);
this.panel3DUserControl1.CommandPanelBackgroundBrush = new LinearGradientBrush(new GradientStopCollection(new GradientStop[] { new GradientStop(Colors.Green, 0), new GradientStop(Colors.White, 0.5), new GradientStop(Colors.Green, 1) }));
this.panel3DUserControl1.MeshDiagramViewport3D.IModelVisualIsSelected += new EventHandler(MeshDiagramViewport3D_IModelVisualIsSelected);
}

#endregion public

#region private

[LicenseProvider(typeof(CAS.Lib.CodeProtect.CodeProtectLP))]
[System.Runtime.InteropServices.GuidAttribute("98925BC5-F27F-4114-BF1E-385BA2AEC9B7")]
private sealed class LicenseProtection : StartUpSplashScreen.LogedIsLicensed<LicenseProtection> { }

private void MeshDiagramViewport3D_IModelVisualIsSelected(object sender, EventArgs e)
{
IModelNodeAdvance imna = panel3DUserControl1.MeshDiagramViewport3D.SelectedIModelVisual.Tag as IModelNodeAdvance;
Expand Down
54 changes: 0 additions & 54 deletions ModelDesigner.DesignStudio/Controls/SaveConstrain.cs

This file was deleted.

Loading

0 comments on commit cfd67d5

Please sign in to comment.