Skip to content

Commit

Permalink
part of a larger work: use AlphaFS::FIle/Directory/Path.* APIs everyw…
Browse files Browse the repository at this point in the history
…here. Also use UNIX `/`instead of MSDOS `\\` where-ever possible.
  • Loading branch information
GerHobbelt committed Oct 13, 2019
1 parent db4908d commit 7ecf0ae
Show file tree
Hide file tree
Showing 120 changed files with 488 additions and 35,770 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
using System.Linq;
using System.Reflection;
using System.Text;
using File = Alphaleonis.Win32.Filesystem.File;
using Directory = Alphaleonis.Win32.Filesystem.Directory;
using Path = Alphaleonis.Win32.Filesystem.Path;

namespace Qiqqa.AnnotationsReportBuilding
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
using System.Linq;
using System.Reflection;
using System.Text;
using File = Alphaleonis.Win32.Filesystem.File;
using Directory = Alphaleonis.Win32.Filesystem.Directory;
using Path = Alphaleonis.Win32.Filesystem.Path;

namespace Qiqqa.AnnotationsReportBuilding
{
Expand Down
3 changes: 3 additions & 0 deletions Qiqqa/AnnotationsReportBuilding/ReportViewerControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
using Utilities;
using Utilities.Files;
using Utilities.GUI.Wizard;
using File = Alphaleonis.Win32.Filesystem.File;
using Directory = Alphaleonis.Win32.Filesystem.Directory;
using Path = Alphaleonis.Win32.Filesystem.Path;

namespace Qiqqa.AnnotationsReportBuilding
{
Expand Down
3 changes: 3 additions & 0 deletions Qiqqa/Backups/BackingUp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
using Qiqqa.Common.Configuration;
using Utilities.DateTimeTools;
using Utilities.GUI;
using File = Alphaleonis.Win32.Filesystem.File;
using Directory = Alphaleonis.Win32.Filesystem.Directory;
using Path = Alphaleonis.Win32.Filesystem.Path;

namespace Qiqqa.Backups
{
Expand Down
3 changes: 3 additions & 0 deletions Qiqqa/Brainstorm/Nodes/ImageNodeContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
using System.Windows.Media.Imaging;
using Qiqqa.Brainstorm.Common.Searching;
using Utilities.Images;
using File = Alphaleonis.Win32.Filesystem.File;
using Directory = Alphaleonis.Win32.Filesystem.Directory;
using Path = Alphaleonis.Win32.Filesystem.Path;

namespace Qiqqa.Brainstorm.Nodes
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ void PDFDocumentNodeContentControl_ToolTipClosing(object sender, ToolTipEventArg

public void ProcessKeyPress(KeyEventArgs e)
{
if (false) { }

else if (Key.P == e.Key)
if (Key.P == e.Key)
{
PDFAnnotation pdf_annotation = pdf_annotation_node_content.PDFAnnotation.Underlying;
PDFDocument pdf_document = pdf_annotation_node_content.PDFDocument.Underlying;
Expand Down
91 changes: 42 additions & 49 deletions Qiqqa/Brainstorm/SceneManager/SceneRenderingControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
using Utilities.Files;
using Utilities.GUI;
using Utilities.Internet;
using File = Alphaleonis.Win32.Filesystem.File;
using Path = Alphaleonis.Win32.Filesystem.Path;

// NOTE: this source file has a few diffs compared to its Utilities/GUI/Brainstorm copy,
// but all changes are deemed improvements or equivalent compared to that codebase,
Expand All @@ -41,7 +43,7 @@ public partial class SceneRenderingControl : Grid, IDisposable
AutoArranger auto_arranger;
DragDropManager drag_drop_manager;
BasicDragDropBehaviours basic_drag_drop_behaviours;

internal SelectedConnectorControl selected_connector_control;
internal SelectingNodesControl selecting_nodes_control;

Expand Down Expand Up @@ -75,7 +77,7 @@ public ConnectorControlManager ConnectorControlManager
{
get
{
return connector_control_manager;
return connector_control_manager;
}
}

Expand Down Expand Up @@ -110,7 +112,7 @@ private void FireScrollInfoChanged()

internal Point mouse_delta_virtual = new Point(0.0, 0.0);
internal Point mouse_current_virtual = new Point(0.0, 0.0);
internal Point mouse_initial_virtual = new Point(0.0, 0.0);
internal Point mouse_initial_virtual = new Point(0.0, 0.0);

internal Point current_viewport_topleft = new Point(0.0, 0.0);
internal Point current_viewport_bottomright = new Point(0.0, 0.0);
Expand All @@ -126,7 +128,7 @@ internal double CurrentScale
}
private set
{
_current_scale = value;
_current_scale = value;
_current_power_scale = Math.Pow(1.2, _current_scale);
}
}
Expand Down Expand Up @@ -155,7 +157,7 @@ internal void ViewportHasChanged()
}

#endregion

#region --- Creation ----------------------------------------------------------------------------------------

public SceneRenderingControl()
Expand All @@ -164,11 +166,11 @@ public SceneRenderingControl()

//this.Background = ThemeColours.Background_Brush_Blue_LightToDark;
this.Background = Brushes.White;
//
// ^^^^ now *this* line hints to me that the Qiqqa Brainstrom copy
// is a copy off the Utilities/GUI/BrainStorm code!
// The Utils copy had the commented out Background setting.
// See also https://github.com/jimmejardine/qiqqa-open-source/issues/26
//
// ^^^^ now *this* line hints to me that the Qiqqa Brainstrom copy
// is a copy off the Utilities/GUI/BrainStorm code!
// The Utils copy had the commented out Background setting.
// See also https://github.com/jimmejardine/qiqqa-open-source/issues/26

this.ClipToBounds = true;
this.Focusable = true;
Expand Down Expand Up @@ -224,9 +226,7 @@ internal void SceneRenderingControl_PostConstructor(BrainstormMetadataControl br

void SceneRenderingControl_KeyDown(object sender, KeyEventArgs e)
{
if (false) {}

else if (e.Key == Key.V && KeyboardTools.IsCTRLDown())
if (e.Key == Key.V && KeyboardTools.IsCTRLDown())
{
DoPaste();
}
Expand Down Expand Up @@ -286,9 +286,9 @@ void ResetViewport()

CurrentScale = 0;

ViewportHasChanged();
ViewportHasChanged();
}

void AddMetaControls()
{
selected_connector_control = new SelectedConnectorControl();
Expand Down Expand Up @@ -461,9 +461,7 @@ private void DoPaste()
{
Logging.Debug("Clipboard paste");

if (false) {}

else if (Clipboard.ContainsText())
if (Clipboard.ContainsText())
{
string text = Clipboard.GetText();
DragDropClipboard_AddText(text);
Expand All @@ -474,7 +472,7 @@ private void DoPaste()
BitmapSource bitmap = Clipboard.GetImage();

string filename = TempFile.GenerateTempFilename("jpg");
using (FileStream stream = new FileStream(filename, FileMode.Create))
using (FileStream stream = File.Create(filename))
{
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
TextBlock myTextBlock = new TextBlock();
Expand All @@ -493,7 +491,7 @@ private void DoPaste()
List<string> filenames = new List<string>();
foreach (string filename in Clipboard.GetFileDropList())
{
filenames.Add(filename);
filenames.Add(filename);
}

DragDropClipboard_AddFiles(new List<string>(filenames));
Expand All @@ -518,9 +516,9 @@ public ConnectorControl AddNewConnectorControl(NodeControl node_from, NodeContro
{
ConnectorControl connector_control = new ConnectorControl(this);
connector_control.SetNodes(node_from, node_to);
return AddNewConnectorControl(connector_control);
return AddNewConnectorControl(connector_control);
}

public ConnectorControl AddNewConnectorControl(ConnectorControl connector_control)
{
scene_changed_timestamp = DateTime.UtcNow;
Expand Down Expand Up @@ -553,7 +551,7 @@ public List<NodeControl> AddNewNodeControlsInScreenCentre(List<object> node_cont
public List<NodeControl> AddNewNodeControls(List<object> node_contents, double left, double top)
{
List<NodeControl> added_node_controls = new List<NodeControl>();

if (0 == node_contents.Count)
{
return null;
Expand Down Expand Up @@ -598,7 +596,7 @@ public NodeControl AddNewNodeControl(object node_content, double left, double to
{
if (!node_control.NodeControlSceneData.Deleted && recurrent_node_content.Equals(node_control.NodeControlSceneData.node_content))
{
return node_control;
return node_control;
}
}
}
Expand Down Expand Up @@ -767,9 +765,7 @@ void SceneRenderingControl_MouseDown(object sender, MouseButtonEventArgs e)
SetSelectedNodeControl(null, IsUserIndicatingAddToSelection());
selected_connector_control.Selected = null;

if (false) { }

else if (next_click_mode == NextClickMode.Hand)
if (next_click_mode == NextClickMode.Hand)
{
if (KeyboardTools.IsShiftDown())
{
Expand All @@ -786,7 +782,7 @@ void SceneRenderingControl_MouseDown(object sender, MouseButtonEventArgs e)
{
mouse_drag_mode = MouseDragMode.Pan;
}

this.CaptureMouse();
e.Handled = true;
}
Expand All @@ -796,7 +792,7 @@ void SceneRenderingControl_MouseDown(object sender, MouseButtonEventArgs e)
StringNodeContent new_node = new StringNodeContent();
new_node.Text = StringNodeContent.DEFAULT_NODE_CONTENT;
NodeControl new_node_control = AddNewNodeControl(new_node, mouse_current_virtual.X, mouse_current_virtual.Y);

this.SetSelectedNodeControl(new_node_control, false);
new_node_control.AttempToEnterEditMode();

Expand All @@ -816,8 +812,7 @@ void SceneRenderingControl_MouseMove(object sender, MouseEventArgs e)

if (next_click_mode == NextClickMode.Hand)
{
if (false) { }
else if (MouseDragMode.Pan == mouse_drag_mode)
if (MouseDragMode.Pan == mouse_drag_mode)
{
if ((Keyboard.Modifiers & ModifierKeys.Control) > 0)
{
Expand Down Expand Up @@ -851,13 +846,11 @@ void SceneRenderingControl_MouseUp(object sender, MouseButtonEventArgs e)
{
UpdateMouseTracking(e, false);

if (false) { }

else if (next_click_mode == NextClickMode.Hand)
if (next_click_mode == NextClickMode.Hand)
{
// Have they selected a whole lot of nodes?
if (MouseDragMode.Select == mouse_drag_mode)
{
{
selecting_nodes_control.Visibility = Visibility.Collapsed;

double min_x = Math.Min(mouse_current_virtual.X, mouse_initial_virtual.X);
Expand All @@ -875,7 +868,7 @@ void SceneRenderingControl_MouseUp(object sender, MouseButtonEventArgs e)
&& node_control.NodeControlSceneData.CentreX - node_control.NodeControlSceneData.Width / 2 >= min_x
&& node_control.NodeControlSceneData.CentreX + node_control.NodeControlSceneData.Width / 2 <= max_x
&& node_control.NodeControlSceneData.CentreY + node_control.NodeControlSceneData.Height / 2 >= min_y
&& node_control.NodeControlSceneData.CentreY + node_control.NodeControlSceneData.Height /2 <= max_y
&& node_control.NodeControlSceneData.CentreY + node_control.NodeControlSceneData.Height / 2 <= max_y
)
{
newly_selected_node_controls.Add(node_control);
Expand All @@ -884,12 +877,12 @@ void SceneRenderingControl_MouseUp(object sender, MouseButtonEventArgs e)

// Add the newly selected nodes...
if (0 < newly_selected_node_controls.Count)
{
{
this.SetSelectedNodeControls(newly_selected_node_controls, IsUserIndicatingAddToSelection());
this.selected_connector_control.Selected = null;
}
}

mouse_drag_mode = MouseDragMode.None;

this.ReleaseMouseCapture();
Expand Down Expand Up @@ -930,7 +923,7 @@ public void New()

public void New(bool force_new)
{
if (!force_new && this.node_controls.Count > 0 && !MessageBoxes.AskQuestion("Are you sure you want to start a new brainstorm? The existing brainstorm will be lost unless you have saved it."))
if (!force_new && this.node_controls.Count > 0 && !MessageBoxes.AskQuestion("Are you sure you want to start a new brainstorm? The existing brainstorm will be lost unless you have saved it."))
{
return;
}
Expand All @@ -943,7 +936,7 @@ public void New(bool force_new)
this.connector_control_manager.Clear();

AddMetaControls();
ResetViewport();
ResetViewport();

brainstorm_metadata = new BrainstormMetadata();
brainstorm_metadata_control.DataContext = brainstorm_metadata.AugmentedBindable;
Expand Down Expand Up @@ -985,10 +978,10 @@ void SaveAsToDisk(string filename)
brainstorm_file_format.ConnectorsV1 = connectors;
brainstorm_file_format.CurrentViewport = new Point((current_viewport_topleft.X + current_viewport_bottomright.X) / 2.0, (current_viewport_topleft.Y + current_viewport_bottomright.Y) / 2.0);
brainstorm_file_format.CurrentScale = CurrentScale;

SerializeFile.Save(filename, brainstorm_file_format);
}

public void SaveToDisk()
{
if (!String.IsNullOrEmpty(brainstorm_metadata.LastOpenLocation))
Expand Down Expand Up @@ -1032,7 +1025,7 @@ public void OpenFromDisk(string filename)
{
ObjControlsLayer.Children.Clear();
ObjNodesLayer.Children.Clear();

scene_changed_timestamp = DateTime.UtcNow;
this.node_controls.Clear();
this.connector_control_manager.Clear();
Expand Down Expand Up @@ -1080,7 +1073,7 @@ public void OpenFromDisk(string filename)

Point point = brainstorm_file_format.CurrentViewport ?? new Point();
current_viewport_topleft.X = point.X - this.ActualWidth / CurrentPowerScale / 2.0;
current_viewport_topleft.Y = point.Y - this.ActualHeight / CurrentPowerScale / 2.0;
current_viewport_topleft.Y = point.Y - this.ActualHeight / CurrentPowerScale / 2.0;

ViewportHasChanged();
RecalculateAllNodeControlDimensions();
Expand Down Expand Up @@ -1229,7 +1222,7 @@ public void Search(string keyword)

internal void ZoomIn()
{
DoViewportScale_AroundScreenCentre(+1);
DoViewportScale_AroundScreenCentre(+1);
}

internal void ZoomOut()
Expand Down Expand Up @@ -1306,7 +1299,7 @@ internal void SetNextClickMode(NextClickMode next_click_mode_)

internal enum MouseDragMode
{
None,
None,
Select,
Pan
}
Expand Down Expand Up @@ -1400,11 +1393,11 @@ internal void SetSelectedNodeControls(List<NodeControl> nodes_new, bool add_to_s

internal void RemoveSelectedNodeControl(NodeControl node_control)
{
for (int i = selected_node_controls.Count - 1; i >= 0 ; --i)
for (int i = selected_node_controls.Count - 1; i >= 0; --i)
{
SelectedNodeControl selected_node_control = selected_node_controls[i];
if (selected_node_control.Selected == node_control)
{
{
ObjControlsLayer.Children.Remove(selected_node_control);
selected_node_controls.RemoveAt(i);
selected_node_control.Selected = null;
Expand All @@ -1429,7 +1422,7 @@ internal bool IsUserIndicatingAddToSelection()
~SceneRenderingControl()
{
Logging.Debug("~SceneRenderingControl()");
Dispose(false);
Dispose(false);
}

public void Dispose()
Expand Down
Loading

0 comments on commit 7ecf0ae

Please sign in to comment.