Esempio n. 1
0
        // 近くの付箋に吸着する
        public static void AdsorbNearFusen(FusenForm fusen)
        {
            foreach (FusenForm ff in fusenList)
            {
                if (ff == fusen)
                {
                    continue;
                }

                if (Math.Abs(ff.Bottom - fusen.Top) <= adsorbMargin && Math.Abs(ff.Left - fusen.Left) <= adsorbMargin)
                {
                    // 上にくっつける
                    if (fusen.Left != ff.Left || fusen.Top != ff.Bottom)
                    {
                        fusen.Left = ff.Left;
                        fusen.Top  = ff.Bottom;
                    }
                }
                if (Math.Abs(ff.Right - fusen.Left) <= adsorbMargin && Math.Abs(ff.Top - fusen.Top) <= adsorbMargin)
                {
                    // 左にくっつける
                    if (fusen.Top != ff.Top || fusen.Left != ff.Right)
                    {
                        fusen.Left = ff.Right;
                        fusen.Top  = ff.Top;
                    }
                }
            }
        }
Esempio n. 2
0
        public static FusenForm AddNewFusen(Point pt)
        {
            FusenForm fusen = new FusenForm();

            if (pt.X < 0)
            {
                fusen.StartPosition = FormStartPosition.WindowsDefaultLocation;
            }
            else
            {
                fusen.StartPosition = FormStartPosition.Manual;
                fusen.SetDesktopLocation(pt.X, pt.Y);
            }
            // 作成日時
            fusen.CreateDateTime = DateTime.Now;
            fusen.UpdateDateTime = fusen.CreateDateTime;

            fusenList.Add(fusen);
            fusen.Show();

            // 非同期処理でデータ保存
            SaveFusenDataAsync();

            return(fusen);
        }
Esempio n. 3
0
        //付箋削除
        public static void DeleteFusen(FusenForm fusen)
        {
            fusenList.Remove(fusen);
            fusen.DeleteImage();
            fusen.Close();

            SaveFusenDataAsync(); // 削除をJSONに反映する
        }
Esempio n. 4
0
        public static void ChangeOrder(FusenForm fusen)
        {
            if (ChangeOrderNum > 0)
            {
                FusenForm ff  = fusenList[ChangeOrderNum - 1];
                int       idx = fusenList.IndexOf(fusen);

                fusenList[ChangeOrderNum - 1] = fusen;
                fusenList[idx] = ff;

                ChangeOrderNum = (ChangeOrderNum + 1) % (fusenList.Count + 1);

                fusenList.InvalidatedAll();
            }
        }
Esempio n. 5
0
        public static void LoadFusenData(string filePath)
        {
            try
            {
                // 読み込み
                using (StreamReader sr = new StreamReader(filePath))
                {
                    List <FusenData> fusenDataList = new List <FusenData>();

                    fusenDataList = JsonSerializer.Deserialize <List <FusenData> >(sr.ReadToEnd());

                    foreach (var fd in fusenDataList)
                    {
                        FusenForm ff = new FusenForm()
                        {
                            CreateDateTime = fd.CreateDateTime,
                            UpdateDateTime = fd.UpdateDateTime,
                            Left           = fd.Left,
                            Top            = fd.Top,
                            Width          = fd.Width,
                            Height         = fd.Height,
                            Text           = fd.Text,
                            FontName       = fd.FontName,
                            FontSize       = fd.FontSize,
                            ImageFilePath  = fd.ImageFilePath,
                            ForeColor      = ColorTranslator.FromHtml(((string)(fd.ForeColor)).Replace("#", "0x")),
                            BackColor      = ColorTranslator.FromHtml(((string)(fd.BackColor)).Replace("#", "0x")),
                            Opacity        = fd.Opacity,
                            ArrangeMember  = fd.ArrangeMember
                        };
                        fusenList.Add(ff);
                        ff.Show();
                        // Showした後でもう一度サイズ指定しないと小サイズの時サイズが変わってしまう
                        ff.Width  = fd.Width;
                        ff.Height = fd.Height;
                    }
                }
            }
            catch (FileNotFoundException)
            {
            }
            catch (Exception ee)
            {
                MessageBox.Show(string.Format("{0}\r\n{1}\r\n{2}", ee.Message, ee.Source, ee.StackTrace));
            }
        }
Esempio n. 6
0
        public static void SaveFusenData(FusenForm fusen, string filePath)
        {
            using (StreamWriter sw = new StreamWriter(filePath))
            {
                List <FusenData> fusenDataList = new List <FusenData>();

                FusenList fusens = new FusenList();
                if (fusen == null)
                {
                    fusens = fusenList;
                }
                else
                {   // 付箋の指定があるときは1つだけのExportなので指定付箋1つだけの新規リストを作る
                    fusens = new FusenList()
                    {
                        fusen
                    };
                }

                foreach (var f in fusens)
                {
                    FusenData fusenData = new FusenData()
                    {
                        CreateDateTime = f.CreateDateTime,
                        UpdateDateTime = f.UpdateDateTime,
                        Left           = f.Left,
                        Top            = f.Top,
                        Width          = f.Width,
                        Height         = f.Height,
                        Text           = f.Text,
                        FontName       = f.FontName,
                        FontSize       = f.FontSize,
                        ImageFilePath  = f.ImageFilePath,
                        ForeColor      = ColorTranslator.ToHtml(f.ForeColor),
                        BackColor      = ColorTranslator.ToHtml(f.BackColor),
                        Opacity        = f.Opacity,
                        ArrangeMember  = f.ArrangeMember
                    };
                    fusenDataList.Add(fusenData);
                }
                sw.Write(JsonSerializer.PrettyPrint(JsonSerializer.Serialize(fusenDataList)));
            }
        }
Esempio n. 7
0
        public static void ExportFusenData(FusenForm fusen)
        {
            if (exportDataFilePath.Length <= 0)
            {
                exportDataFilePath = dataFilePath;
            }
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.InitialDirectory = Path.GetDirectoryName(exportDataFilePath);
            sfd.FileName         = Path.GetFileName(exportDataFilePath);

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                SaveFusenData(fusen, sfd.FileName);

                if (exportDataFilePath != sfd.FileName)
                {
                    exportDataFilePath = sfd.FileName;
                    SaveSettingAsync(); // Pathが変わったので設定保存
                }
            }
        }
Esempio n. 8
0
        // 付箋を整列させる
        public static void ArrangeFusen(ArrangeType arrangeType, FusenForm fusen)
        {
            Rectangle rc = Screen.GetBounds(fusen);
            Point     pt = new Point(rc.Left, rc.Top);

            if (arrangeType == ArrangeType.ScreenRight)
            {
                // 右端に整列(整列対象メンバーのみ)の準備
                int maxWidth = fusenList.Max((a) => { return(a.ArrangeMember ? a.Width : 0); });
                pt.X = rc.Right - maxWidth;
            }
            else if (arrangeType == ArrangeType.Fusen && fusen != null)
            {
                pt.X = fusen.Left;
                pt.Y = fusen.Bottom;
            }

            foreach (FusenForm ff in fusenList)
            {
                if (arrangeType == ArrangeType.Fusen && fusen == ff)
                {
                    continue;
                }

                if (!ff.ArrangeMember)
                {
                    continue;
                }

                ff.Left = pt.X;
                ff.Top  = pt.Y;
                pt.Y    = ff.Bottom;

                if (pt.Y >= rc.Bottom)
                {
                    break; // 画面下にはみ出たら終わり
                }
            }
        }
Esempio n. 9
0
        // 画面端に吸着する
        public static void AdsorbScreenEdge(FusenForm fusen)
        {
            Point     pt = new Point(fusen.Left, fusen.Top);
            Rectangle sc = Screen.GetBounds(fusen);

            if (Math.Abs(sc.Left - fusen.Left) <= adsorbMargin)
            {
                fusen.Left = sc.Left;
            }
            if (Math.Abs(sc.Top - fusen.Top) <= adsorbMargin)
            {
                fusen.Top = sc.Top;
            }
            if (Math.Abs(sc.Right - fusen.Right) <= adsorbMargin)
            {
                fusen.Left = sc.Right - fusen.Width;
            }
            if (Math.Abs(sc.Bottom - fusen.Bottom) <= adsorbMargin)
            {
                fusen.Top = sc.Bottom - fusen.Height;
            }
        }
Esempio n. 10
0
        public static void GatherFusen(FusenForm fusen)
        {
            Rectangle rc = Screen.PrimaryScreen.Bounds;
            Point     pt = new Point(rc.Left + rc.Width / 2, rc.Top + rc.Height / 2);

            if (fusen != null)
            {
                pt = new Point(fusen.Left, fusen.Top);
                pt.Offset(20, 20);
            }

            foreach (FusenForm ff in fusenList)
            {
                if (fusen == ff)
                {
                    continue;
                }

                ff.Left = pt.X;
                ff.Top  = pt.Y;
                pt.Offset(20, 20);
                ff.Activate(); // 順番に重ねるためにActivateする
            }
        }
Esempio n. 11
0
 public static void SaveFusenData(FusenForm fusen)
 {
     SaveFusenData(fusen, dataFilePath);
 }